Brutalism • The Applied Go Weekly Newsletter 2024-09-22
Your weekly source of Go news, tips, and projects
What's your preferred configuration language? YAML, JSON, TOML, or environment variables? Or do you suffer from a general configuration language allergy? Maybe there's a CUrE. Now you're CUErious, huh?
Not so fast. First, you have to read through the featured articles, one by one. And listen to the podcasts.
Come again? YOU chose to subscribe, didn't you? Now you have to go through all of it.
¯\_(ツ)_/¯
Featured articles
What's in an (Alias) Name? - The Go Programming Language
Type aliases exist since Go 1.9, for refactoring purposes. They don't support type parameters, but this will change in Go 1.24. Robert Griessemer explains how generic type aliases work.
Notes on running Go in the browser with WebAssembly - Eli Bendersky's website
How to call Go from JS, how to manipulate the DOM from Go, and how to run a web assembly (that supports only a single thread) on a separate thread using web workers.
Implementing an Order Processing System: Part 1 - Setting Up the Foundation
Temporal is a framework for writing long-running workflows in Go. This six-part, hands-on howto guide shows how to build an order processing system with Go, Temporal, Gin, sqlc, PostgreSQL, and Docker.
Podcast corner
Go Time: How I lost my (old) job to AI
"AI cannot take my job." – "Why?" – "I am unemployed." While there is truth to this bitter joke, AI already has changed the way we work, and will continue to do so. Sharon, Steven, Kent, and Johnny share some stories from their day-to-day worklife.
Cup o' Go: 🦙 I hate that I like Cup o' Go, LLMs, and many proposals
Not sure why Johathan and Shay have these mixed feelings, but maybe they just sympathize with the author of "I hate that I like Golang" on Reddit. (Also linked via the quote of the week.)
Spotlight: CUE—your next configuration language?
There are reasons why JSON or YAML are popular: they have a rather simple syntax, they cover almost any configuration need, and they are popular. (Yes, I know, this is recursive argumentation, but popularity is a positive feedback loop.)
A typical configuration for a server with a host and a port might look like this in YAML:
exampleServer:
host: appliedgo.net
port: 3000
Looks clear and precise, but is this really the best way to configure your apps?
The problems of traditional configuration langauges
Here is what YAML, JSON, and TOML configuration files don't tell you:
- The type of a field. Sure,
host
is probably a string andport
looks like an integer, but can you really tell? - Allowed values or ranges. Can I specify a port below 1024? What's the maximum value allowed?
- Whether a field is mandatory. What if I omit the host value?
- Default values. If a field isn't mandatory, what's the default value?
(I won't list other quirks of YAML & co. at this point.)
Is there a way out?
Try CUE for a change
The majority of problems with traditional configuration languages can be traced back to a lack of a schema specification.
The CUE language allows defining schemas for your data. Even better, you can define the schema in CUE itself, no special schema syntax needed. And CUE is a validation language at heart, and so it can validate configuration against a given schema.
Here is an example: The CUE schema of the above YAML configuration:
#Server: {
host!: string
port: int & >=1024 & <=65535 | *8080
}
In a very compact and concise way, these lines describe the requirements for a valid Server configuration:
- "#Server" is a schema definition (as it is prefixed by a hash)
- The host field must be a string
- The host field is mandatory (note the exclamation mark)
- The port must be an integer between 1024 and 65535
- The port field defaults to 8080 if omitted
The corresponding configuration is straightforward:
exampleServer: #Server & {
host: "appliedgo.net"
port: 3000
}
This snippet says, "I adhere to the #Server schema, and I provide these host and port values."
No ambiguities left.
CUE comes with a cue
command that can validate configurations and export them to YAML or JSON.
But using CUE with Go is where the fun starts.
- Use the
cue
package to read in and validate CUE, YAML, or JSON configuration - Generate CUE schemas from Go
- Validate Go types against CUE schemas
CUE schemas can become a single source of truth for your data types and configurations. If this sounds too hyperbolic, have a look at hof
. This project uses CUE as a single source of truth to generate and validate about everything you need for building an application.
Want to give CUE a try in your next project?
Quote of the Week: Go is brutalism
Good Go is to programing what Brutalism is to architecture. Go is stripped bare of embellishment, of pretty, its striped down to purely what is needed to function. Good go Is blocky, its verbose, it never gets cute it doest try to be fancy or "abstract".
More articles, videos, talks
Building package-level, runtime configurable logging ala log4j in Go
The DoltHub team wanted a log4j
-style logger with file-driven configuration for Go, so they built their own.
Yet another anonymous work search
A Go job search tool for the Ukraine. Source code here.
go-grid
A one-million-checkboxes clone in Go.
BTW, as I browser the site of the creator of the original One Million Checkboxes page, I came across this list of totally weird game implementations, such as a breakout game in Google Calendar or Flappy Bird running in macOS' Finder.
This is the BEST Golang Context Package Tutorial - YouTube
The context package might not be the most intuitive package in Go, as it is highly connected to a particular context (no pun intended): passing context information along an HTTP request call chain and across goroutine boundaries.
Sets in Go
Go has sets! It's just that they are hidden inside maps. Willem Schot's interactive set tutorial pull sets out of the shadows.
Projects
Libraries
GitHub - koss-null/list: go 1.23 implementation of linked list with iterators and generics support
An alternative to container/list
that supports iterators, generics, and easy synchronization.
GitHub - sphireinc/Hydra: A Go library that dynamically hydrates structs with data from multiple databases, offering flexibility and ease for database integration in software development.
Think "one-way, single-table, single-row ORM". Hydra fills a struct from a row of a database table.
GitHub - emiago/diago: Short of Dialog + GO. Library/Framework for building VOIP solutions in GO
Be the next Graham Bell and build your own telephone empire with this voice-over-IP (VOIP) library. Or start small and build an in-house communications server.
MoniGO - Go App Performance Dashboard in 10 Seconds with R-T Insight! | Product Hunt
If your performance measurements start to scratch at the limits of /usr/bin/time -v
, it's time to switch to the (probably) fanciest performance dashboard library available for Go apps.
GitHub - 49pctber/shamir: a practical example of Shamir's secret sharing scheme
"Eight executives have keys for the company's safe. You need five keys to open the safe."
Tools and applications
GitHub - justinfx/minio_cleaner: Minio Object Access-Time cleaner
Minio allows setting a time-to-live with granularity of 1 day. minio_cleaner
enables shorter TTL durations and TTL based on last access time.
Convert Image to ASCII Art | Free Online Tool |Kushal Chapagain
Nice beginner's project, repo is here
GitHub - OpusMag/what-cmd: What-cmd is a command line tool written in Go that gives you an easy way to find the terminal command you're looking for when you've forgotten it
Is your brain like a swiss cheese (that is, full of holes) and you keep forgetting CLI commands? Or are you new to the terminal? what-cmd
is an interactive command finder that finds any command (but unfortunately not my car keys).
GitHub - Hawaii66/slime-mold-simulation
"Roast my "Slime mold simulation" with Ebiten", wrote the author in /r/golang
. Now I have images of roasted slime mold in my head that won't go out anymore.
GitHub - mg52/redis-mnist-vector-search
This project uses Redis' RediSearch and RedisJSON modules to achieve 96% accuracy on finding images from the MNIST data set of hand-written digits.
Completely unrelated to Go
Personnel update
When firing people, companies are usually super bad at communicating the situation properly. Time to take their communication style to other parts of one's life.
Bash namerefs for dynamic variable referencing
Make your Bash scripts more readable with namerefs. (Or—my suggestion—have some LLM turn them into Go.)
Why Scrum is Stressing You Out - by Adam Ard
Scrum sprints are nothing but an endless treadmill that doesn't let you pause for even just a second..
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