I recently received an issue report that ijq was performing slowly. The issue claimed that, when used on a large (16 MB) JSON file, ijq was “too slow to be usable”. I downloaded the test file which …
I made up a neat little pattern in Go the other day. It’s a way to represent a state change in a system by exposing different APIs for different states, while only holding state in a single underlying struct. I’m sure I’m not the first person to invent this, and it may already a name, so please let me know if you know of one. I’m going to show an instance of the pattern first and the motivation after.
Go first came onto my radar about 9 years ago when I came across MuMax during my PhD studies. While I’ve touched it briefly, I wouldn’t consider myself to have used it in anger until recently, when I started a job that uses it as one of it’s primary languages for API development. I’ve had experience in writing C and C++ code, but more recently I’ve done a lot of Python, so going back to Go has felt oddly like a throwback to those compiled languages I’ve used before, with a bit of modern sparkle.
It may seem silly, but go run is my favorite part about go. Want to run your code? go run main.go. It is so stupidly simple that I could tell my mom about this command, and she would immediately understand. Like with most things in go, the real power in this command is in the effortless understanding of how to build and run everyone’s code.
But I can run node main.
In response to @cadey@pony.social's blog post about wanting retry loops in #Golang, I wrote terrible hack using using the proposed iterator syntax. https://go.dev/play/?v=gotip
var err error
for range backoff(&err, 1 * time.Second) {
if err = something1(); err != nil {
continue
}
if err = something2() ; err != nil {
continue
}
}
Mat Ryer, principal engineer at Grafana Labs and host of the Go Time podcast, shares what he's learned from more than a dozen years of writing HTTP services in Go.
Mat Ryer, principal engineer at Grafana Labs and host of the Go Time podcast, shares what he's learned from more than a dozen years of writing HTTP services in Go.
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 :-).
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.
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.
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).
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
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
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.