Not another article about Go 1.22, please! • The Applied Go Weekly Newsletter 2024-02-11
Your weekly source of Go news, tips, and projects
Is it already half a year since I posted an article on appliedgo.com/blog? It is, obviously. (Note to self: Reserve more time for writing articles.) Luckily, every Go release is a great topic to write about. The downside: Everyone(*) else writes about the latest Go release, too.
(*) Or so it feels.
The last article about Go 1.22 you need to read
Let's face it: Almost all Go 1.22 articles have been posted way before the release, based on the release candidates. So what's better than to collect them all into a meta article?
The last article about Go 1.22 you need to read
Visualizations in code playgrounds
If you're a dev blogger and you're not sold to codapi.org's embeddable, multi-lingual playground yet, you should be after reading this article.
Visualizations in code playgrounds
Retry function in Go
Generic retry functions without generics need reflection — or do they? Redowan Delowar inspects three ways of writing a retry function.
Podcast corner
All podcasts rave about Go 1.22. All podcasts? No. Dominic St-Pierre decided to have Matt Boyle as Guest instead.
Cup o' Go
Cup o' Go | 🆕 Most of what you need to know about Go 1.22
Go Time
What's new in Go 1.22 with Carlana Johnson (Go Time #302)
go podcast()
go podcast() | 027: Debugging in Go with Matt Boyle
Go tip of the week: You (probably) don't need a debugger
"What debugger shall I use? Does this IDE have a debugger UI? Does it support <debugger>?"
Wrong questions.
Firing up a debugger should only be the last resort.
Debugging code is tedious and slow. Most likely, debugging costs you more time than taking the extra effort to write robust, tested code.
How to avoid this time sink:
- Be clear about the code you want to write, before you write it. Have a functional specification to follow.
- Use unit tests. Go has them built-in, for free. Every function without I/O is a perfect candidate for unit-testing.
- Use integration tests to cover all functions with I/O, as well as the interplay of all components.
- Follow TDD principles and techniques. Test-Driven Development has proven its merits for creating high-quality code.
- Use "quick-and-dirty tracing". With packages like
appliedgo.net/what
orgithub.com/davecgh/spew
, you can insert ad-hoc logging to observe how your code behaves. (And remove the logging easily afterwards.)
With a little more time invested up-front, you can save a lot of time later.
Quote of the week: There's never time
There’s never going to be time to build something great, because it’s hard to do great work without giving it your undivided attention, and undividing your attention always has a cost. The trick is to become ok with that.
More articles, videos, talks
Today with two "sub-features" because sometimes, multiple articles about the same subject pop up within the same week. Must be the zeitgeist...
Sub-feature: contexts
Goroutines without context are like... (a burger without the bun, falafel without hummus,... <insert silly analogy here>).
Should contexts be used for long-running operations? Matt T. Proud got tired of hearing this question and started an article series on contexts in Go. This is part 1.
Contextualizing Context Scopes
Sub-feature: the Raft consensus protocol
Achieving consensus in distributed systems is difficult. The Raft protocol is a tested and proven consensus algorithm. Here is another Go implementation.
Achieving Consensus in Go: A Raft Implementation
Sarthak Kumar shows how to implement a distributed K/V store on top of hashicorp/raft
.
Gokey: Building a distributed key-value store using RAFT consensus protocol in Golang | LinkedIn
Still more articles!
TinyGo on Pimoroni Cosmic Unicorn: Part 1 by zegl
Believe it or not: Cosmic unicorns can run Go code.
Implement a WebSocket server in Go (Golang) | golangbot.com
Web sockets are the missing full-duplex version of HTTP. Naveen Ramanathan's article covers theory and practice of writing a WebSocket server using Gorilla's
websocket
package.
Testing out Profile-Guided Optimization on Dolt's SQL Benchmarks
Profile-guided optimization (PGO) in the wild. DoltHub tested PGO against their database and found considerable decreases in read and write latencies. – By Zach Musgrave.
Epic of Code: Web Development in Go
The author wrote a Go web app to learn to write Go web apps. The result is this online tutorial.
Another take on Go project structure. The author promotes the KISS principle: Start simple, but not too simple.
All releases - The Go Programming Language
If you're not ready to jump to Go 1.22 yet, here is the latest patch release for Go 1.21.
You can find third-party libraries for each and every task, making development more convenient. But dependencies can be a burden. Daniel Taylor helps you reduce your dependencies to a healthy level.
Siddhesh Khandagale creates a tool for creating cold emails on the command line. Looking at the resulting email, I would not recommend this for production use! At least if you want to get a job at that company. (To be fair, with an extensive prompt that includes the job description and your CV, I would guess the output gets drastically better!) But let's not forget that the whole point of the article is to show you how to use the OpenAI API, so feel free to adjust the code to your requirements.
Reinventing The Wheel: OpenAI, Anyscale & OctoAI APIs Through Go — Part 1 | LinkedIn
Soumit Salman Rahman experiments with three APIs that other people would use Python for. But not us Gophers!
Projects
Libraries
GitHub - nichady/golte: Render Svelte components in your Go http handlers.
Write Go web apps with Svelte but without NodeJS as a production dependency. Worth noting that Golte is a library, not a framework.
The author frequently faced the problem of insecure webhooks throughout his developer life. This package is an attempt to make webhook access safer.
GitHub - ankorstore/yokai: Simple, modular, and observable Go framework for backend applications.
The author's PHP team gradually moved to Go and created helper code that gradually developed into a kind of framework for developing backend apps (API servers, workers, etc).
GitHub - callebjorkell/copper: Copper keeps REST APIs honest
The idea: "Test API specifications alongside of the contract tests, to verify that both spec and implementation say the same thing."
GitHub - expectto/be: Wide collection of Golang assertions: Gomega and Gomock compatible matchers
A test helper library for declarative tests. (Similar to Be or
is
.)
Kickstart your next Go+HTMX+Hyperscript+Pico.css project. Requires
gow
(Go Watch) for hot reload functionality.
Tools and applications
GitHub - chasankm/sudoku-solver
What? Sudokus should be solved by humans? C'mon...
Access the common genarative AI API's through a single gateway with a unified API.
Completely unrelated to Go
Why software is way behind its potential, and what dishwashers got to do with it.
Why We Can't Have Nice Software - Andrew Kelley
If you run a small or solo software business, or plan to start one, big tech might not be amused. Be prepared.
How to deal with receiving a cease-and-desist letter from Big Tech
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