A compilation of knowledge about the Go Programming Language
- Official documentation
- Books
- Software engineering
- Data structures
- Semantics
- Web development
- Monitoring
- REST API
- Error handling
- SSH
- Tooling
- Databases
- Concurrency
- Containers
- Background processes ("daemons")
- Misc (unclassified or difficult to classify)
- The Go Programming Language: The Bible. [Alan A. A. Donovan and Brian W. Kernighan]
- Network Programming with Go (No Starch Press): In depth analysis of how to properly handle http servers, TCP/UDP connections, client and server timeouts, networking error handling, telemetry, etc. [Adam Woodbeck]
- Let's go: Hands-on/practical book to build Web applications in Go. [Alex Edwards]
- Let's go further: Advanced patterns for building APIs and web applications in Go. Metrics, Authentication, JSON responses, DB operations, etc. [Alex Edwards]
- Concurrency in Go (O'Reilly) [Katherine Cox-Buday]
- A theory of modern Go: Reasoning behind avoiding global state and init() functions, and instead use dependecy injections and/or interfaces. [Peter Bourgon]
- Go best practices, six years in: Best practices summed up in a long article. Everything from handling dependencies, to repository layout, testing, logging, etc. [Peter Bourgon]
- Go for Industrial programming: Another great article with best practices around: adequately handling concurrency and goroutine's creation and definition (properly handling the interruption of a goroutine), observability (metrics, logging, tracing), dependencies, testing, etc. [Peter Bourgon]
- Go (Golang) - understanding the object oriented features with structs, methods, and interfaces: How Go implements OOP paradigma in a different and more effective way. [Unix Sheikh]
- Use internal packages to reduce your public API surface: A brief intro into a correct taxonomy of a project's folders and subfolders, specially the meaning of the internal packages subfolder. [Dave Cheney]
- Five suggestions for setting up a Go project: An intro into the logic behind packages' names, directory structure in a project. A good article to know how to setup a project before actually starting to work on it. [Dave Cheney]
- Simple Go project layout with modules: The best article I have encountered that explains how to layout a Go project for client consumption as both a library and/or as an executable. [Eli Bendersky]
- Why you shouldn't use func main() in Go: An article explaining that calling a function
run()
inside main, and passingos.Args
andstd.out
, etc to it, is more testable than just using main(). [Mat Ryer] - We already have Go 2: A tour of general changes in the Go ecosystem (GOPATH, modules, etc.) since its inception.
- Interface segregation in action with Go: A simple explanatory guide on how to properly use and compose interfaces and the benefits of structuring a program in such a way.
- Interfaces are not meant for that: [Preslav Rachev]
- Functional Options Pattern in Golang: An explanatory article on how to use the functional options pattern to provide options or initialize fields in a struct with a constructor, instead of passing the field values as parameters. This design pattern is supported in other articles by Dave Cheney. [Michael Zalecki]
- Go Data Structures: A description of the memory implementation of some basic types in Go: bytes, int, floats, structs, pointers, strings and slices. Furthermore, a description of the functions for data structure creation
make
andnew
. [Russ Cox] - Maps and memory leaks in Go: An article explaining the fact that maps can only grow (even after garbage collection) and how they can potentially increase the memory consumption of a program to dangerous levels. [Teiva Harsanyi]
- The Go Programming Language Specification: Official language specification
- Golang Interfaces Explained: Definition, meaning and usefulness of interfaces. [Alex Edwards]
- Why Infer Types?: The reasoning behind infering types instead of explicit type definitions. [Nate Finch]
- How to use variadic functions in Go: A DigitalOcean's guide on using variadic functions. [DigitalOcean]
- Implementing enumerations in Golang: A guide showing a way to implement enumerations and the reasoning behind this specific implementation. [William Kennedy]
- Unmarshalling JSON with Null Boolean values in Go: A guide on how to properly unmarshal Null values from a JSON object. Especially relevant when handling SQL databases with columns with NULL values.
- Embedding in Go part 1: Structs in structs: Part 1 of a 3 part series which focuses on teaching the reasoning behind different compositional patterns with structs and interfaces. [Eli Bendersky]
- Embedding in Go part 2: Interfaces in interfaces: Part 2 of a 3 part series which focuses on teaching the reasoning behind different compositional patterns with structs and interfaces. [Eli Bendersky]
- Embedding in Go part 3: Interfaces in structs: Part 3 of a 3 part series which focuses on teaching the reasoning behind different compositional patterns with structs and interfaces. [Eli Bendersky]
- Using functional options instead of method chaining: A guide on using functional options (as defined by Dave Cheney) with detailed examples. [Jon Calhoun]
- The ultime guide to writing a Go tool: A guide on how to use semantic/language analysis tools from the standard library to write a Go tool. [Fatih Arslan]
- How I write HTTP services in Go after 13 years: Great read with some more advanced insights into how to structure and develop a backend web service. [Mat Ryer]
- Validation Snippets for Go: Common validation patterns for data being sent to a server through a POST request [Alex Edwards]
- A Guide To Writing Logging Middleware in Go: Step by step guide to write logging middleware. [Matt Silverlock]
- Which Go router should I use?: Comparison and evaluation of popular router options for Go. [Alex Edwards]
- Hot to Rate Limit HTTP requests: Excellent article about how to properly set a maximum rate of requests in a given time from a particular user. [Alex Edwards]
- Serving static files and web apps in Go: An introduction into using the standard library built-in functionality to create static file servers. The guide also explains how to integrate the static file servers with servers handling dynamic requests. [Eli Bendersky]
- Proper HTTP shutdown in Go: An article explaining in detail how to graciously/properly shutdown a Go HTTP server.
- Context (in Middlewares and Handlers): An article explaining when it makes sense to pass down data to further server handlers using an
*http.Request
context
. [Peter Bourgon] - What is a broken piper error: TCP/HTTP connections and pools: An article explaining TCP/HTTP connection pools and when and why a broken pipe write error could take place.
- Logging in Go with Slog: The ultimate guide: In-depth article explaining how to use the "new"
log/slog
package.
- Go HTTP servers with TLS: A guide on how to configure TLS authentication for both servers and clients. It is very understandable, easy to follow and provides extra resources and a detail description on how to create self-signed certificates for a testing environment. [Eli Bendersky]
- Go and Proxy servers (HTTP proxies): A guide on how to develop reverse- and forward proxies with Go. [Eli Bendersky]
- Sign in with GitHub in Go: Using OAuth and GitHub as an identity provider. [Eli Bendersky]
- Collecting Prometheus metrics in Golang: A very detailed guide about collecting metrics with Go using Prometheus and finally displaying them in a dashboard with Grafana. [Gabriel Tanner]
- Getting response status code with middleware: A StackOverflow thread on how to capture the status code of a response that has already been sent to a client with the help of the
negroni
library. [StackOverflow]- ResponseWriter in negroni:
negroni
's implementation of aResponseWriter
, which has additional very useful methods missing in the standard library.
- ResponseWriter in negroni:
- REST servers in Go part 4: Using OpenAPI and Swagger: A guide on how to generate both documentation and an opinionated API server and/or client from a Swagger definition. [Eli Bendersky]
- Why Go error handling is awesome: A discussion and comparison of error handling in Go with other languages. A good explanation about giving context to errors with
fmt.Errorf()
. [Raul Jordan] - Error handling guidelines for Go: The logic behind properly handling errors, be it with the error interface or by returning sentinel values. [Jay Conrod]
- Go (Golang) - Errors and panics: An argument for verbosity in error handling in Go [Unix Sheikh]
- SSH port forwarding with Go: A guide on how to create an SSH tunnel with Go. [Eli Bendersky]
- An overview of Go's Tooling: A general overview of the multiple options of the
go
command. [Alex Edwards]
- Export data, the secret of Go's fast builds: A brief overview about export data in the build process, and how Go tries to speed up the build process. [Jay Conrod]
- Installation with Go Language can be simpler: Some useful recommendations regarding static linking through use of CGO_ENABLED env variable, stripping binaries at compilation, version in binaries, cross-compilation, etc.
- Customizing Go binaries with build tags: Tutorial on how to use build tags for cross-compilation. [DigitalOcean's Go series]
- 3 ways to embed commit hash to Go programs: A guide on how to embed a commit hash to a Go program at build time. [Red Hat]
- go delve - The Golang Debugger: An introduction into how to use
delve
from the command line to debug programs and tests. The article has a very good table summary of importantdelve
commands for debugging.
- Testing in Go: go test: In depth description to start configuring a project for testing: test coverage, flags and options of go test, test result caching, etc. [Ilija Eftimov]
- Don't use a different interface for testing: A good explanatory article explaining why not using the same interface for testing is not a good idea due to code coverage.
- Testing a CLI command with cobra: An explanation on to how to test a CLI implemented with cobra.
- Testable Examples in Go: Official documentation on how to integrate example code to the documentation.
- Life of a Go module: How GOPROXY, checksum and in general the module handling system works. [Jay Conrod]
- Go database/sql tutorial
- Organising database access in Go: Choosing between handling database connection pools with global variables, own types and dependency injection through methods and context resources. [Alex Edwards]
- GORM: Golang ORM Package: How to use and setup an Object Relational Mapper in Go to facilitate writing SQL queries.
- Configuring sql.DB for better performance: Configuring maximum values for open and idle connections to a db, and setting a connection timeout. [Alex Edwards]
- Learning Go’s Concurrency through illustrations: Very basic guide about goroutines and channels with many illustrations. Blocking and non-blocking channels. [Trevor Forrey]
- Writing a One-to-Many Event Feed Library in Go: An introduction with example code on how to handle the Pub/Sub design pattern with channels in Go, to basically multicast information to many clients in a concurrent-safe way. [Raul Jordan]
- Is it ok to leave a channel open?: StackOverflow discussion with great sources about the reasoning for not always closing channels. [StackOverflow]
- Stdlib: context package documentation: The documentation of the standard library
context
package has a good and concise explanation on why to use contexts and how to use them properly. - How to use contexts in Go: Semantic and syntactic explanation on how to implement contexts in concurrent programs. [DigitalOcean's Go series]
- Context and structs: Official Go blog article on properly handling contexts.
- The Go scheduler: High-level description of the interplay of OS threads, goroutines and contexts. How blocking syscalls are handled. [Daniel Morsing]
- The Go netpoller: How polling primitives of the underline OS are used by Go in order to not block every single thread with a blocking syscall while doing networking. [Daniel Morsing]
- Go's work-stealing scheduler: Description of how the work-stealing algorithm of the Go runtime works [rakyll]
- The Go runtime scheduler's clever way of dealing with system calls: More in-detail description of how syscalls are characterized into good and bad syscalls, and the good syscalls are wait upon by the sysmon goroutine [Chris Siebenmann]
- Data race patterns in Go A study of real-world data races in Golang: An article by a dev team at Uber, in which they talk about the data race patterns that they found by scanning the vast Go codebase at Uber (also published as a peer-reviewed article).
- Ice cream makers and data races: A demonstration and explanation of data races taking place with interfaces in part due to the memory model of interfaces. [Dave Cheney]
- Are Go maps sensitive to data races?: An explanation of why maps are more susceptible to causing data races and problems in concurrent applications, than other more simple data structures (as slices). [Dave Cheney]
- Using GoLang with Docker: Step by step guide to run a Go app in a Docker container, with example Dockerfile.
- Building Docker Images for Static Go Binaries: Creating a very small size Docker image for a static Go binary. [Kelsey Hightower]
- Supervised FreeBSD rc.d script for a Go daemon: Run a go program as a supervised daemon in FreeBSD.
- Write and auto-deploy daemons in FreeBSD: How to write and auto-deploy daemons using the
daemon(8)
FreeBSD functionality and rc. - Four Steps to Daemonize Your Go Programs: How to correctly setup a daemon in Go, handle signals SIGTERM, SIGHUP, logging, etc. [Ilija Eftimov]
- runtime: support for daemonize #227: GitHub thread regarding the difficulties of running a Go program as a usual Unix daemon
- Running Go Applications in the Background: Using Supervisor to run a Go program in the background, handle logging, email notifications and restarts if the program crashes. [Matt Silverlock]
- Reading list for a training: Reading list has a lot of further interesting links
- Upgrading Go in Ubuntu
- Between Golang and Elixir: A guide of how to integrate Go and Elixir together, and when it makes sense to use them.