Post details
Mat Ryer has been writing Go since r59—a pre `1.0` release—and has been building HTTP APIs and services in Go for the past eight years. He shares his experience and insights.
Mat Ryer has been writing Go since r59—a pre `1.0` release—and has been building HTTP APIs and services in Go for the past eight years. He shares his experience and insights.
I strive to respect everybody’s personal preferences, so I usually steer clear of debates about which is the best programming language, text editor or operating system. However, recently I was asked a couple of times why I like and use a lot of Go, so here is a coherent article to fill in the blanks of my ad-hoc in-person ramblings :-).
How to unpublish/redact/undo/retract a Go release (3 mins read).
How to retract a release version of a Go version, without risking folks automagically upgrade to that version.
How do you represent a JSON field in Go that could be absent, null
or have a value? (5 mins read).
Why it's surprisingly hard to work out a field has been sent or whether it's explicitly null, when using Go's encoding/json
.
Isolated loop variables, range over integers, math/rand v2 and enhanced routing.
Golang plugin system over RPC. Contribute to hashicorp/go-plugin development by creating an account on GitHub.
Debug-level logging for developers (only!). Contribute to appliedgocode/what development by creating an account on GitHub.
A tool to generate Go data types from JSON Schema definitions. - GitHub - omissis/go-jsonschema: A tool to generate Go data types from JSON Schema definitions.
🦩 Tools for Go projects. Contribute to nikolaydubina/go-recipes development by creating an account on GitHub.
A simple, powerful library for forms and prompts in the terminal 🤷🏻♀️ - GitHub - charmbracelet/huh: A simple, powerful library for forms and prompts in the terminal 🤷🏻♀️
Automatically generate Go test boilerplate from your source code. - GitHub - cweill/gotests: Automatically generate Go test boilerplate from your source code.
The Golang linter that checks usage of github.com/stretchr/testify. - GitHub - Antonboom/testifylint: The Golang linter that checks usage of github.com/stretchr/testify.
A colorful slog handler
Today, if you publish a popular Go module on a URL and you lose control of the URL (through, eg, domain expiration and having the domain snatched up), you have a problem that's probably more or less impossible to deal with short of making blog/Fediverse/etc posts about the situation. Go module identity is tied to URLs with more or less no external override or way to automatically announce and see problems (individual people can override for their usage, but that doesn't scale).
Getting Go modules to work with nested GitLab groups (3 mins read).
How to get Go modules to work with nested groups in GitLab for public or private repos.
Performing a v2 release of a Go module (1 mins read).
How to prepare your Go module for its first breaking change release.
How we reduced oapi-codegen's dependency overhead by ~84% (6 mins read).
An example of how to reduce the size of a Go module's dependencies by taking advanage of Go module pruning.
Which version of Go was used to compile this binary? (2 mins read).
How to use a few means to work out what version of Go a given binary was compiled with.
Go client library for accessing the Backstage REST API - GitHub - tdabasinskas/go-backstage: Go client library for accessing the Backstage REST API
Gotchas with pointing Go modules to a fork, when building an installable module (3 mins read).
A gotcha around how to pin a Go module to a fork, if you're building a module that should be go install
able.
A Go package providing errors with a stack trace and structured details. https://pkg.go.dev/gitlab.com/tozd/go/errors
For more content like this, buy my in-progress eBook, Data Serialization in Go, and get updates immediately as they are added! This post contains links and notes for the presentation I gave on March 5, 2020, for the Golang Rotterdam meetup group. Download the slides in PDF format, or you can view the Go Present source file. Previous blog posts on related topics: “Slightly” custom marshaling JSON Arrays as Go structs
neovim plugin to run gomodifytags. Contribute to simondrake/gomodifytags development by creating an account on GitHub.
Ok, I lied, there's no weird trick. However, you can easily reduce a Go binary size by more than 6 times with some flags and common tools. Note: I don't actually believe a 30MB static binary is a problem in this day and age, and I would not trade (build
Setting up a matrix for GitHub Actions with Go's go.mod
and specific versions (2 mins read).
How to use a Go setup matrix in GitHub Actions that can target the go.mod
version and arbitrary other version(s).
Go’s <code>defer</code> and <code>t.Cleanup</code> have similar semantics, but there’s a good reason to prefer the use of <code>t.Cleanup</code> specifically in the presence of parallel subtests.
Creating global middleware for net/http
servers in Go (1 mins read).
How to wrap net/http
servers in Go with middleware(s) on every request.
What Go versions are my modules and dependencies targeting? (1 mins read).
Without using go mod vendor
, how you can look at the version of Go that each of your modules and dependencies target.
Why is Go trying to upgrade my go.mod
to Go 1.21? (1 mins read).
Why you may be seeing Go trying to upgrade the Go version in your go.mod
to Go 1.21.
Amazon Web Services (AWS) is deprecating the go1.x runtime on Lambda, this is currently scheduled for December 31, 2023. Customers need to migrate their Go based lambda functions to the al2.provided runtime, which uses Amazon Linux 2 as the execution environment. I think this is a bad thing for a couple of reasons: There is no automated migration path from existing Go Lambda functions to the new custom runtime. Customers will need to manually refactor and migrate each function to this new runtime, which this is time-consuming and error-prone.
How and why we started annotating all our Go tests with <code>t.Parallel()</code>, and why you might want to consider doing so too.
Alex shares his insights from building half a dozen popular Go CLIs. Which can you apply to your projects?
Go is built for grug brained programmers like me. grug brain developer not so smart, but grug brain developer program many long year and learn some things although mostly still confused
This page contains the data that is available to the go list command, we use golang templates to extract subsets of this data below Get imports for the current directory package go list -f '{{range …
Running commands against every module in a Go multi-module project (1 mins read).
How to run commands like go test
when using a multi-module Go project.
How do you test a database without a database? Don't worry, this isn't one of those Zen puzzles. I have something more practical, but equally enlightening, in mind. Let’s use the adapter pattern to solve the riddle.
Analysing GitHub Pull Request review times with SQLite and Go (3 mins read).
How measuring how long code review took as a team lead to being able to change our processes, and then deliver much more effectively.
We're excited to announce that Socket now supports the Go programming language.
In many languages, on of the things I find myself doing is maping over a list to extract some field. For example, coverting a []Person to []Name. Most languages these days have ways to do this pretty easily: Kotlin: people.map { it.Name } JavaScript: people.map(p => p.Name) Rust: people.map(|p| p.Name) Scala: people.map(_.Name) With generics, Go finally can do this in a type safe manner: Map(people, func(t Person) string { return t.
Last week AWS published a blog post advising that the go1.x Lambda runtime will be deprecated and people should migrate to provided.al2. I was already using the newer runtime, but I also learned from the blog post that AWS SAM can now build Go Lambda functions for the newer runtime - no more Makefiles required!
Announcing golang.org/x/tools/cmd/gonew, an experimental tool for starting new Go projects from predefined templates
Go 1.21 has some awesome new functionality that improves the developer experience and performance.