GeistHaus
log in · sign up

Using Go Modules

go.dev

An introduction to the basic operations needed to get started with Go modules.

12 pages link to this URL
Context Cancellation and Server Libraries like gRPC and net/http

Pop quiz, hot shot: what is the behavior of func f (as defined below) when it is called from a bare gRPC method or HTTP handler as go f(ctx) using the context.Context provided to the handler?1 1 2 3 4 5 6 7 8 9 10 11 func f(ctx context.Context) { // Flimsily make it improbable for this function to return while the // handler is serving. time.Sleep(time.Second) select { case <-time.After(5 * time.Second): log.Println("5s") case <-ctx.Done(): log.Println("canceled") } } Where the handlers look like this:

0 inbound links article en posts ApiGoSwe
Go: Package-Centric Organization

Organizing source code is a critical skill in software mastery, and this remains true in Go. Unfortunately the skill of idiomatic organization in one language does not necessarily translate to another. What makes this trickier is that code organization happens at several levels: the build system the packaging system in code in the file system To understand why, consider this Unified Modeling Language (UML) diagram of these levels and their relationships when using Go:

0 inbound links article en posts GoSweApiCritiqueCultureDogma
Open source is like a second job

When I started working as a software engineer, I really wanted to work full time in open source. I've been lucky enough to spend a decent chunk of my career doing exactly that. Much of that work has been incredibly rewarding, but for readers interested in taking a similar path, I want to share an insight and a warning.

0 inbound links article en careeropen-source
Use Branches With Go Modules

When developing with Go on a team, it is useful to have a good branching strategy so you can work together as a team and not tromp on each others changes. But how do you use Go modules with a branching strategy? It’s easy to refer to another project (even at a certain version) – but branches seem to offer a bit of a challenge. The official guidance involves using the specific commit hash for the module you want, like this:

0 inbound links article en posts