About hosting a Go service • The Applied Go Weekly Newsletter 2024-05-19
Your weekly source of Go news, tips, and projects
Whether you build an online service in Go as a side project or for your business, at one point you have to decide where and how to host your service. Should you rent a proprietary hosting solution, or better grab some open-source software and start hosting everything by yourself?
In the essay below (occupying the section where the Go tips use to be), I waffle about a third way, which is, after all, not really distinct from the other two options.
But first, enjoy some top news about Go:
Build your own CI system in Go
"Which CI system do you use?" — "My own."
Build your own CI system in Go (Part 1) | Just a Random Dev Blog
Simplicity is Contagious
Which article about Go's simplicity starts with… pointers? This one.
Simplicity is Contagious - bugramming
Using Cuelang With Go for LLM Data Extraction
CUE is a special kind of configuration language: CUE is its own schema definition language. Hence it can do more than just expressing configuration. Milos Gajdos uses CUE to validate the output of an LLM.
Using Cuelang With Go for LLM Data Extraction - Cybernetist
Podcast corner
Cup o' Go
Your weekly update on upcoming meetings and conferences, submitted, approved, and rejected proposals, new tools, packages, and more.
Cup o' Go | This just in! When is a constructor that returns an interface appropriate? 🤔
Essay — Service or self-hosting? Or: how FOSS can make a difference
If a fish swims belly-up, it's probably dead. No meal. If you're lucky, you'll find some mushrooms nearby to eat instead.
If a service company goes out of business (or changes the ToS, plans, pricing, or anything that makes it unacceptable for you to continue your business relationship with them), you might try finding another, similar service. But it wouldn't be the same service, just like mushrooms aren't fish.
Free and open-source software (FOSS) changes the game completely. With open-source software, you are in control over the services you use.
Which means, on the other hand, that you'd also be responsible for everything: installing, maintaining, troubleshooting, and anything else that comes with self-hosting.
But hey, why not combine both?
Numerous companies offer paid services on top of their open-source software. (“FOSS as a Service,” or FOSSaaS, if you will.) Why would you want to use such a service? You could self-host the software and stay independent, after all.
Hosted services based on FOSS offer advantages over, and remove disadvantages of, self-hosting.
- You don't need to provision infrastructure
- No installation steps required
- Maintenance is done for you
- The services are always up to date with the latest features and fixes
- You get higher uptime than with self-hosted services (unless you have employees on pager duty, at additional cost)
And here is the main advantage that separates FOSS services from closed-source service companies: If a FOSS company stops selling their hosted service, you might find another company step in and offer the exactly same service, or else you can fall back to self-hosting.
Your work is only minimally disrupted, compared to migrating from one proprietary service to another, incompatible service.
During the recent weeks, while looking for application deployment and hosting options, I came across a few interesting service companies that operate in FOSS mode. I thought I share them here as examples and as an inspiration for you to find more of these best-of-both-world services.
Unikraft.org (note the k)
- The software: A build-and-deploy kit for unikernel applications.
- The service: Deploy unikernel applications to their cloud. Kraft.cloud comes with a Go SDK for lifecycle management.
- Use case for Go projects: Unikernels start within microseconds and can scale to zero. If you have a web service that is idle most of the time, consider running it in a scale-to-zero unikernel.
- Fallback steps: Build, package, and run unikernels with the
kraft
CLI tool.
NanoVMs.com
- The software: A build-and-deploy kit for unikernel applications.
- The service: Deploy unikernel applications to the major cloud platforms or on-prem.
- Use case for Go projects: Same as with Unikraft.
- Fallback steps: Build, package, and run unikernels with the
ops
CLI tool.
Bacalhau.org (Expanso.io)
- The software: Distribute data processing jobs to where the data is, rather than collecting data for central processing. Written in Go.
- The service: Managed services to help adopt, operate, and integrate Bacalhau. Also, Lilypad, a project on top of Bacalhau, aims at enabling compute node owners to sell CPU power to Bacalau jobs via smart contracts.
- Use case for Go projects: Small Go binaries are best for being sent to dozens or hundreds of data processing locations, especially if the jobs are frequently modified (think scientific research).
- Fallback steps: Own your compute nodes, run Bacalhau via the CLI tool.
Coolify.io
- The product: A management platform for self-hosted services. Self-host with the comfort of serverless.
- The service: Self-hosting the Coolify service requires a dedicated VM instance. For about the same money, you can use a hosted version of Coolify instead.
- Use case for Go projects: A convenient server management and app deployment platform for your projects.
- Fallback steps: Get a VM and deploy the Coolify services there. As part of the Coolify concept, the workload already runs on your own machines (or rented ones).
Encore.dev
- The product: A backend development platform for distributed and event-driven systems. Encore supports Go and TypeScript projects. They just turned fully open-source a couple of days ago.
- The service: A hosted version of Encore with preview environments, secrets management, distributed tracing, and more goodies.
- Use case for Go projects: Encore comes with a Go SDK that takes quite some work off the devs shoulders.
- Fallback steps: Build your apps with the
encore
CLI tool and host them on a container-based infrastructure of your choice.
Earthly.dev
- The product: A build framework for self-contained, consistent, portable, and language-agnostic builds. Earthly switched from source-available to a FOSS license in 2023. Written in Go.
- The service: A hosted build automation platform.
- Use case for Go projects: Being language-agnostic, Earthly works well with Go projects.
- Fallback steps: Run builds with the
earthly
on your own machines.
In summary, there are numerous options of putting your project into the caring hands of others without completely giving away control. Hosted FOSS services remove all the risks of vendor lock-in.
Where do you host your Go services?
Quote of the week: Hard to read
The purpose of reading code is to deduce how data is being processed. When code is written in such a way to purposely obfuscate what the data is and how it's processed, we say the code is hard to read.
– Hasen Judi (see the Unrelated to Go section)
Comment: I would scratch the word "purposely". It doesn't take willfulness to obfuscate data processing in code. Inexperience or carelessness are other valid explanations. Luckily, Go rejected the noun-first paradigm of object-oriented languages and fosters a verb-first approach instead. Rather than asking, "what objects does my code need to perform these actions?", Gophers can ask directly, "what actions does my code need to perform?" and write their code by following the data processing flow.
More articles, videos, talks
Running/Testing AWS Lambda function locally in Golang
AWS Lambda functions do not have to run on AWS. Here is how to run them locally.
Conquering Errors in Go: A Guide to Returning and Handling errors | by DK | May, 2024 | Ride
Why if err != nil { return err }
is wrong, and what to do instead.
Reconfigurable CORS middleware with jub0bs/cors :: jub0bs.com
The jub0bs/cors
package is evolving. In this article, Julien Cretel explains why he relaxed the requirement of immutable configuration.
Introduction to Generative AI with Go
Daniel Whitenack, author of Machine Learning with Go, runs a 1-hour webinar on generative AI with Go.
GitHub - samuelyuan/PolytopiaMapEditor: Open source map editor for The Battle of Polytopia
This project could be interesting to you if you (a) play Polytopia, or (b) want to see how to write an editor for (tiled) maps, or (c) want to examine a Fyne app.
Announcing GoReleaser v1.26 - The last v1, probably
The most important detail is right at the beginning:
V2 will not be a big update, rather, it’ll be the same as v1.26, but removing all the deprecated stuff.
If you use Goreleaser, this might be a good time to check if your Goreleaser config uses anything that has been deprecated, to ensure a smooth upgrade to v2 when it's out.
Projects
Libraries
GitHub - coder/hnsw: In-memory HNSW for Go
Do fast nearest-neighbor search in high-dimensional data with Hierarchical Navigable Small World graphs. Here is the Go package you need.
GitHub - Yifeeeeei/butterknife: A tool for printing stuffs along with its callers in Golang
Quick-and-dirty debugging with Print commands.
GitHub - williammoran/slogerror: Utilities to allow Go programs to easily transfer logging context to errors
If you use slog
's logger.With()
to add context, you'll have to recreate the context for building an error message. Except if you use slogerror
.
GitHub - salihzain/nakedi18n: A simple, naive, painless, composable i18n golang package.
A scratch-your-own-itch project: The author wasn't satisfied with existing internationalization (i18n) packages and created nakedi18n
.
GitHub - k-capehart/go-salesforce: Salesforce REST API client written in Go
The author found only abandoned or insufficiently documented Salesforce wrappers, so they rolled their own.
Tools and applications
GitHub - Vaniog/Snaker
The classic snake game in the browser, for one or two players.
GitHub - maaslalani/pom: Pomodoro timer in your terminal
Pomodoro without the tomato flavor.
GitHub - letieu/tank-online: Multiple player tank game inside terminal
Readme line 1: "A simple tank game just for learn golang" — Mmhmm, ok.
Readme line 2: "Use redis as game server" — Whoa, now THIS is an unconventional idea! (Or maybe I just don't know much about game servers.)
GitHub - Razikus/go-ssh-to-websocket: Super simple SSH to websocket written in GO. With XTERM example to consume also
Run an SSH terminal in your broswer, talking to the SSH server via WebSockets.
GitHub - saalikmubeen/greenlight
Forget fan fiction, here is fan non-fiction. This repo is a reader-created supplement to Alex Edward's book Go Further.
GitHub - chapar-rest/chapar: Chapar is a simple and easy to use api testing tools aims to help developers to test their api endpoints. it will support http and grpc protocols.
Many REST test clients I came across recently carried the "light" label, but this one seems to strive for Postman-like functionality. Including importing Postman collections. The project is in beta but installation is still via git clone
& go build
.
GitHub - thedunston/bash_cli_zt
A terminal-based controller for ZeroTier, a peer-to-peer VPN similar to Tailscale or NetBird.
GitHub - baalimago/clai: Command line artificial intelligence - Multi-vendor generation in your terminal
Want to understand a CLI tool's output or get feedback on some local code? Ask AI, or clai
, to be precise.
Completely unrelated to Go
The Straight Forward Programming Manifesto
Writing convoluted, unstructured, obfuscated code is embarassingly easy. It takes conscious effort to move in the opposite direction and keep one's code clean, readable, and maintainable. Here is a language-agnostic primer.
Modern SQLite
Anton Zihyanov started a series about SQLite features that might not be commonly known but that might save your database-handling life someday.
Happy coding! ʕ◔ϖ◔ʔ
Questions or feedback? Drop me a line. I'd love to hear from you.
Best from Munich, Christoph
Not a subscriber yet?
If you read this newsletter issue online, or if someone forwarded the newsletter to you, subscribe for regular updates to get every new issue earlier than the online version, and more reliable than an occasional forwarding.
Find the subscription form at the end of this page.
How I can help
If you're looking for more useful content around Go, here are some ways I can help you become a better Gopher (or a Gopher at all):
On AppliedGo.net, I blog about Go projects, algorithms and data structures in Go, and other fun stuff.
Or visit the AppliedGo.com blog and learn about language specifics, Go updates, and programming-related stuff.
My AppliedGo YouTube channel hosts quick tip and crash course videos that help you get more productive and creative with Go.
Enroll in my Go course for developers that stands out for its intense use of animated graphics for explaining abstract concepts in an intuitive way. Numerous short and concise lectures allow you to schedule your learning flow as you like.
Christoph Berger IT Products and Services
Dachauer Straße 29
Bergkirchen
Germany