First Principles First! • The Applied Go Weekly Newsletter 2024-11-03
Your weekly source of Go news, tips, and projects
First Principles First!
Hi ,
Back to the basics: How does an HTTP router work? How does Go's time formatting work? How does fuzz testing work? I think that once in a while, it can't hurt to gather some fundamental knowledge or refill a few memory cells with basic patterns and mechanisms. At a deeper (or higher?) level, this kind of curiosity leads to a universal way of uncovering the world's knowledge called First Principles thinking.
The featured articles are examples of practicing First Principles thinking, and I took that opportunity to theorize a bit about the merits of adopting this thinking pattern to software development and why Go is the ideal language for this.
No one wants to live by the saying, "Days of coding saved me hours of thinking!"
Featured articles
Writing an HTTP Router for AWS Lambda Functions From Scratch With Go | Dimitar Andreev
HTTP routers just work. But how? Follow Dimitar Andreev on his endeavor to implement a router from scratch.
How to format time in Go/Golang | Tural Asgarov | Tural Əsgərov
This bookmark-worthy article does not only decrypt Go's time formatting string but also contains a bunch of other tips and tricks around using times.
Fuzz Testing Go HTTP Services. A guide on fuzz testing in Go. | by Alex Pliutau | Oct, 2024 | ITNEXT
A crash course in fuzzing. Let Go generate test data that you never dreamed of.
Podcast corner
go podcast() 046: Let's talk about Rust with John Arundel
John Arundel of Bitfield Consulting is Dominc St-Pierre's guest in this go podcast()
episode, where John explains why he considers Go and Rust a dream team.
Cup o' Go | 🌳 Roots & Trees: OpenRoot, and Cedar to the rescue for access control
Jonathan and Shay discuss the statuses of a few Go proposals and interview Justin McCarthy of StongDM about authentication and the Cedar policy language.
Spotlight: Developing software with First Principles thinking
When I glanced over the featured articles, I felt they had an underlying topic in common. It took me a while and a few decomposing steps to discover what it is: First Principles thinking, a method of reasoning that starts with decomposing things down to the fundamental axioms.
That's what the featured articles above basically do: They pick an HTTP router apart, split time format strings into their atomic elements, or look into the mechanisms of fuzz testing.
Go is actually great at helping you with First Principles thinking! The language itself is relatively small and straightforward, with few hidden mechanisms. Rather than hiding complexity behind layers of abstraction, Go exposes the fundamental mechanics of what's happening. Even Go's standard library follows this pattern: it provides the building blocks rather than high-level abstractions, encouraging developers to understand and compose these blocks according to their needs. What a great opportunity to wrap your brains around the building blocks of development and achieve mechanical sympathy.
Why does this matter? Because when you understand the fundamentals:
- Your code becomes slim and clean and maintainable—you won't blindly include unnecessary dependencies that bloat your code but rather write simpler solutions supported by fundamental principles
- Debugging becomes more intuitive—you know where to look when things go wrong because you have internalized the way Go code works.
- Architecture decisions become more informed—you can better evaluate trade-offs (as with decisions like, for example, "monolith vs microservice" or "SQL vs NoSQL")
Mastering Go—and software development in general—isn't about learning more abstractions. It's about understanding the fundamentals deeply and applying them wisely.
Quote of the Week: Feedback
“Feedback is a gift” as a blanket statement should be used less. There’s a ton of nonsensical feedback that’s not actionable, given by people who have no clue. Actionable feedback is a gift.
More articles, videos, talks
How to Document Your Go Api
Use Swag for generating API docs for your Go REST API.
A Useful Pattern for Nil Channel Values in Go
How to enable or disable select statement branches using nil-valued channels. (Is this clear or clever coding? You decide.)
How to Implement Server-Sent Events in Go - YouTube
Video version of Alex Pliutau's article of the same name.
Jia Tanning Go code
With a bit of Unicode trickery, *_test.go
files can be made to be compiled as non-test code.
TIL: "jia tanning" seems to be the new term for "adding trojan horses to other people's codebase".
Exploring Go's UTF-8 Support: An Interesting Limitation : r/golang
Unicode is... demanding. And it's no wonder: getting 154,998 characters and 168 scripts under one roof is not an easy task. Unicode has tackled this, but languages that support Unicode will have to deal with rare edge cases, as in this example of the Tamil language.
With pointers to further discussions of the topic, shared by Rob Pike.
27.6% of the Top 10 Million Sites are Dead | by TonyWang | Oct, 2024 | Medium
The results may not be accurate and are intensely debated, but to me, the main point is that the code tested 10 million sites within 10 minutes (that's roughly 16K sites per second), which is not that bad. (I wonder if network bandwidth is a limiting factor.)
The parallel test bundle, a convention for Go testing
Running tests concurrently comes with caveats. Brandur Leach presents a test convention that helps to make sub-tests safe for concurrent execution. It's as easy as adding a struct and a helper function to isolate test bundle instances from each other.
Checking linearizability in Go
Linearizability is a strong single-object consistency model that requests that operations take place atomically and in consent with the real-time ordering of these operations. Phil Eaton describes how to use Porcupine, a linearizability checker, to, well, check linearizability of a distributed register.
Projects
Libraries
GitHub - cornejong/golucide: Lucide icons for go
Lucide Icons is a large collection of SVG icons with a clean style and no JavaScript dependencies. golucide
brings them to Go.
goship.it
GoShip.it, a frontend component library based on DaisyUI components translated to Templ, is now open source. (Link to the repo)
GitHub - guregu/emojify: server-side rendered Twemoji for Go
Twemojiy are Twitter-style emojis, released under CC-BY 4.0 and MIT. emojify
helps render them on the server.
GitHub - kelindar/search: Go library for embedded vector search and semantic embeddings using llama.cpp
A semantic search library for small datasets (<100k entries) for easy integration in Go apps.
GitHub - guycipher/k4: High-performance open-source, durable, transactional embedded storage engine designed for low-latency, and optimized read and write efficiency.
The feature list of this storage engine might imply that there is SQLite under the hood, but the project has absolutely no external dependencies.
Tools and applications
tslocum/godoc-static: Generate static Go documentation - Rocket 9 Labs
Turn your local Go module documentation into a static website. godoc-static
reads your local projects or Go cache and generates a zip file of static HTML pages containing your projects' godoc
documentation.
GitHub - enigma522/netcut-cli: A simple tool to cut people's network with ARP spoofing, written in golang
This sounds like black hat tool but it has legitimate use cases for admins and sysops.
GitHub - eibd/MatrixFX
MatrixFX is pretty much what the name suggests (to those, at least, who know the Matrix movies): An animation of the famous green rain of glyphs.
GitHub - olzhasar/mess: A cli tool to clean up your development mess.
Clean up your ~/dev
directory with style! This helper lists repos with uncommitted changes and outdated repos, and cleans up temporary files.
SuvarnaNarayanan/migrator: dead simple SQL migration manager
mig
decouples the migration from teh databse and hosts the migration tables in a separate SQLite instance.
GitHub - amrdb/data-services: A high-performance, distributed data access layer implementing request coalescing and hash-based routing to reduce database load and prevent hot partitions.
Discord's article "How Discord Stores Trillions of Messages" was the inspiration for this "distributed data access layer (gRPC) implementing request coalescing and hash-based routing to reduce database (Cassandra) load and prevent hot partitions."
GitHub - manjurulhoque/book-store: A full-stack book store application built with Go for the backend and Next.js for the frontend.
Don't look at the screenshots or else you'll want to open a bookstore right ahead with this app, and the world will lose another great Gopher.
GitHub - fred1268/nostalgia: A tribute to the Dark Priests
A flashback into the 1980's demo scene, powered by Ebitengine.
GitHub - ufukty/govalid: simple code generator implements Validate method on enums
Go doesn't have enums, but now you can validate them! govalid
scans your Go code for constants defined with a given type and produces a Validate() method for that type that checks if a value of that type is one of the defined constant values. Verifiable enums without an enum type.
GitHub - Systenix/go-cloud: go-cloud is is an open-source CLI tool designed to streamline the development of cloud-native Go backend services.
A full-fledged framework for building Go web applications, following Clean Architecture principles
GitHub - picosh/pubsub: A generic pubsub implementation for Go
Yet Another Pub-Sub Library™? No, picosh
declares itself as "the simplest pubsub system over ssh." Which means you can publish and subscribe right from the command line. (The Readme is quite short, better check the homepage.)
GitHub - hypermodeinc/modus: Modus: an open source, serverless framework for building intelligent functions and APIs, powered by WebAssembly
Modus turns functions into serverless GraphQL endpoints. All you do is write a function, and Modus compiles it, generates an API schema, and runs the function in a sandboxed enviornment for every request.
Completely unrelated to Go
How I use LLMs
Many developers aren't convinced of the time-saving capabilities of AI coding assistants. I made some quite good experiences with Continue.dev (a VSCode extension), but Karan Sharma discovered Aider as the tool to stick with. Here is Karan's experience report.
Ghostty 1.0 is Coming
Looking for a good (maybe even great) terminal emulator for macOS and Linux? No, there is nothing new to grab right now, but if you wait until December, you can try Ghostty 1.0 that Mitchell Hashimoto will release as an open-source project then. The only "drawback" (no, not really) is that Mitchell decided to write Ghostty in Zig and C, rather than in Go, despite the fact that the company he founded (Hashicorp) wrote virtually all their tools and apps in Go.
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