Skip to content

The Go Programming Language

November 16, 2023
February 16, 2015

Build simple, secure, scalable systems with Go

materials before 2019 should probably be removed

The Go Programming Language
Go (programming language) - Wikiwand
Go: A Documentary
What reasons are there to not use Go (programming language)? - Quora
The Why of Go - YouTube

Go 1 and the Future of Go Programs - go.dev
How to Write Go Code - go.dev
Getting started with VS Code Go - YouTube 2021-01
Learn Go Programming - Golang Tutorial for Beginners - YouTube 2019-06, 6:39:57
Golang Tutorial for Beginners | Full Go Course - YouTube 2021-12, 3:24:58

Learn Go Fast - Full Tutorial Series - YouTube 2023-09, Alex Mux
avukadin/goapi: Playing around with go

Awesome Go
avelino/awesome-go: A curated list of awesome Go frameworks, libraries and software
tenntenn/gopher-stickers: gopher stickers
travis-ci/gimme: Install go, yay! nvm for Go

Tap the power of Google's Go language | InfoWorld
Understand Go in 5 minutes - Je suis un dev
Practical Go | Dave Cheney

go command - cmd/go - pkg.go.dev
Go command and packages cheat sheet | Opensource.com

go mod init <package>

go run a.go
go build a.go
go run -x -v a.go
go build -x -v a.go
go build -v PACKAGE
go build -ldflags="-s -w" a.go # trim binary

go run folder
go build folder
# if `go get` has network issue
go env -w GOPROXY=<https://goproxy.io,direct>

GOPATH was required before Go 1.14 (2020-02), see #GOPATH
Now it defaults to $HOME/go and stores packages and GOBIN

Version Manager

kevincobain2000/gobrew: Go version manager. Superr simple tool to install and manage Go versions. Install go without root. Gobrew doesn't require shell rehash.
Go Version manager — gobrew. Install and manage Go versions on Mac… | by pulkit kathuria | web-developer | Medium

stefanmaric/g: Simple go version manager, gluten-free

syndbg/goenv: Like pyenv and rbenv, but for Go.

moovweb/gvm: Go Version Manager requires several host tools

Go 2

Toward Go 2 - go.dev
Go2 · golang/go Wiki
Go 2 Draft Designs - go.dev
Go 2 Draft Designs

Go team proposes parametric polymorphism • DEVCLASS

Tools

Vulnerability Management for Go - The Go Programming Language

Linting

Introduction | golangci-lint
golangci/golangci-lint: Fast linters Runner for Go
A Complete Guide to Linting Go Programs

go install github.com/golangci/golangci-lint/cmd/golangci-lint

Docs

godoc -http=":6060"
# docs for all installed packages at http://localhost:6060/pkg

godoc pkg Label  # look up function/type

Godoc: documenting Go code - go.dev
Go Doc Comments - The Go Programming Language
Static analysis features of godoc - go.dev

Godocs - Effortless documentation for your go packages - YouTube
godoctricks package - github.com/fluhus/godoc-tricks - Go Packages
godoc: Tips & Tricks. Go has a great emphasis on simple… | by Elliot Chance | Medium

Golds -Go 101
go101/golds: An experimental Go local docs server/generator and code reader implemented with some fresh ideas.

Editor/IDE

The best Go language IDEs and editors | InfoWorld

Gopls on by default in the VS Code Go extension - The Go Programming Language
golang/vscode-go: Go extension for VS Code
vscode-go/features.md at master · golang/vscode-go
GopherCon 2019: Rebecca Stambler - Go, pls stop breaking my editor - YouTube old way -> gopls

LiteIDE X
visualfc/liteide: LiteIDE is a simple, open source, cross-platform Go IDE.

Commentaries

Comparing Elixir and Go - via @codeship | via @codeship
The success of Go heralds that of Rust - George Hosu - Medium
Go: the Good, the Bad and the Ugly
What Go Programming Language does and does not have
Why Go gets exceptions right | Dave Cheney
My reflections on Golang - DEV Community 👩‍💻👨‍💻
Rust vs. Go: How to choose | InfoWorld
Why Go Is Not Good :: Will Yager

Rust Vs Go: A Hands-On Comparison with web services
Rust vs Go : Hands On Comparison - YouTube

Golang Is A Poorly-Designed Language | by Paul Folbrecht | Sep, 2023 | Medium
Golang Is Poorly Designed | Prime Reacts - YouTube Primeagen's comment is more pertinent:

Golang is BAD for SMART PEOPLE - YouTube

Go's Worst Feature? - YouTube bash on naked return

Compile

containous/yaegi: Yaegi is Another Elegant Go Interpreter

How a Go Program Compiles down to Machine Code - Hacker Noon

Use -ldflags=-w flag to disable DWARF to reduce binary size

vladimirvivien/go-cshared-examples: Calling Go Functions from Other Languages using C Shared Libraries build .so

gopherjs/gopherjs: A compiler from Go to JavaScript for running Go code in a browser

web-assembly#Go

How to Use //go:generate · The Ethically-Trained Programmer
How to Use //go:embed · The Ethically-Trained Programmer

GoReleaser - GoReleaser

Cross Compile

Cross compilation with Go 1.5 | Dave Cheney
Cross compilation just got a whole lot better in Go 1.5 | Dave Cheney
Cross-compiling made easy with Golang | Opensource.com
Golang 跨平台交叉编译 | Tony Bai
How to cross-compile Go programs for Windows, macOS, and Linux

go tool dist list
GOOS=linux GOARCH=arm64 go build -v PACKAGE
GOOS=darwin GOARCH=amd64 go build
GOOS=windows GOARCH=amd64 go build -o app.exe app/main.go
GOOS=wasip1, GOARCH=wasm go build # WAPI preview 1
# use `upx` is binary is too large

mitchellh/gox: A dead simple, no frills Go cross compile tool

Cgo

C? Go? Cgo! - go.dev
cgo command - cmd/cgo - pkg.go.dev
cgo · golang/go Wiki

cgo is not Go | Dave Cheney
Statically compiled Go programs, always, even with cgo, using musl — Dominik Honnef using Zig is easier

Go 与 C 语言的互操作 | Tony Bai
探讨 docker 容器对共享内存的支持情况 | Tony Bai
Python and Go : Part IV - Using Python in Memory

CGO_ENABLED=1 go build
CGO_ENABLED=1 GOOS=linux go build
# zig produces static linked executable, with your choice of libc
CGO_ENABLED=1 GOOS=linux CC="zig cc -target aarch64-linux-musl" go build

runtime: provide centralized facility for managing (c)go pointer handles · Issue #37033 · golang/go

Package Manager

Deprecation of 'go get' for installing executables - The Go Programming Language
Use go get for package management of go.mod
Use go install for executables

go install example.com/cmd@latest

Managing dependencies - The Go Programming Language
PackageManagementTools · golang/go Wiki
The Saga of Go Dependency Management GopherAcademy

Modules

previously vgo, "versioned Go"
alternative to GOPATH, added in Go 1.11 (2018-08)
control with GO111MODULE environment variable
default on if go.mod exists in Go 1.14 (2020-02)
package and binary management before Go 1.16 is quite messy

Modules · golang/go Wiki
Go Modules Reference - The Go Programming Language

Packages and Modules in Go (Golang) - Part 1 - Welcome To Golang By Example
Packages and Modules in Go (Golang) - Part 2 - Welcome To Golang By Example

Go update all modules - Stack Overflow
Go Modules | RheinardKorf.com

go mod init  # init project
go mod tidy  # sync `go.mod` with project

go get [MODULE]  # get/upgrade dependency
go install # build and install commands

go list -m -u all # list upgrades
go get -u # upgrade dependencies to latest
go get -u=patch # upgrade dependencies limited to patch version
go get -u -t # upgrade test dependencies
go get -u ./... # upgrade recursively in any subdirectories
go mod tidy ./... # after upgrade

Environment Variables

go command - cmd/go - Go Packages

go env

GOPATH

How to Write Go Code (with GOPATH) - The Go Programming Language
Why is GO111MODULE everywhere, and everything about Go Modules (updated with Go 1.17) - DEV Community 👩‍💻👨‍💻

The App Engine SDK and workspaces (GOPATH) - go.dev

stdlib

Standard library - pkg.go.dev
fmt package - fmt - pkg.go.dev
log package - log - pkg.go.dev
strings package - strings - pkg.go.dev
strconv package - strconv - pkg.go.dev
reflect package - reflect - pkg.go.dev

json package - encoding/json - pkg.go.dev
Golang JSON Gotchas That Drove Me Crazy But I Have Learned to Deal With

fs package - io/fs - pkg.go.dev
Walking with filesystems: Go's new fs.FS interface — Bitfield Consulting build memory fs

Packages

go get can install dependencies given the URL
std package are located at $GOROOT/pkg/<platform>/
no std package are located at $GOROOT/src/

Go Packages - Go Packages repository
godocs.io
Go Report Card | Go project code quality report cards

Projects · golang/go Wiki
golang-standards/project-layout: Standard Go Project Layout
Package names - go.dev

The Go Programming Language Specification - go.dev Package initialization
The Go init Function | TutorialEdge.net
go 打包机制 | 李乾坤的博客

Write packages, not programs — Bitfield Consulting
From packages to commands — Bitfield Consulting

mobile module - golang.org/x/mobile - Go Packages
mobile module - go.dev/x/mobile - pkg.go.dev
golang/mobile: [mirror] Go on Mobile

jefferyjob/go-easy-utils: Quick toolbox for common data processing developed by Go language。Go 语言开发的常用数据处理的快捷工具箱。
go-vgo/gt: Commonly used functions and tools for the Go programming language

mitchellh/protostructure: Encode and decode Go (golang) struct types via protocol buffers.

ulikunitz/xz: Pure golang package for reading and writing xz-compressed files
mholt/archiver: Easily create & extract archives, and compress & decompress files of various formats

afero package - github.com/spf13/afero - pkg.go.dev
spf13/afero: A FileSystem Abstraction System for Go

rate package - golang.org/x/time/rate - Go Packages

uber-go/zap: Blazing fast, structured, leveled logging in Go.
stats_api package - gopkg.in/fukata/golang-stats-api-handler.v1 - Go Packages

Masterminds/squirrel: Fluent SQL generation for golang

google/gopacket: Provides packet processing capabilities for Go
dreadl0ck/gopcap: Fast Golang PCAP Reader & Benchmark Comparison recommends pcapgo, benchmarks, not using binary.Read()

import

goimports command - golang.org/x/tools/cmd/goimports - pkg.go.dev

理解 Go import |虞双齐的博客
理解 Golang 包导入 | Tony Bai

// import declaration       Local name of Sin
import   "lib/math"         math.Sin
import m "lib/math"         m.Sin
import . "lib/math"         Sin  // include symbols to local namespace
import _ "lib/math"         // suppress unused warning, run init, no load symbol

fmt package - fmt - Go Packages
Go 学习笔记:Println 与 Printf 的区别,以及 Printf 的详细用法_zgh0711 的博客-CSDN 博客

fmt.Printf("%T\n", variable)  // print type of variable

// The next line prints: coco
fmt.Printf("%[2]v%[1]v%[2]v%[1]v", "o", "c")
# General
%v the value in a default format
   when printing structs, the plus flag (%+v) adds field names
%#v a Go-syntax representation (with GoStringer interface, like Python's `__repr__`) of the value.
%T a Go-syntax representation of the type of the value

# %v default
bool:                    %t
int, int8 etc.:          %d
uint, uint8 etc.:        %d, %#x if printed with %#v
float32, complex64, etc: %g
string:                  %s
chan:                    %p
pointer:                 %p

# Boolean
%t the word true or false

# Integer
%b base 2
%c the character represented by the corresponding Unicode code point
%d base 10
%o base 8
%O base 8 with 0o prefix
%q a single-quoted character literal safely escaped with Go syntax.
%x base 16, with lower-case letters for a-f
%X base 16, with upper-case letters for A-F
%U Unicode format: U+1234; same as "U+%04X"

# Floating Point
%b decimalless scientific notation with exponent a power of two,
 in the manner of strconv.FormatFloat with the 'b' format,
 e.g. -123456p-78
%e scientific notation, e.g. -1.234456e+78
%E scientific notation, e.g. -1.234456E+78
%f decimal point but no exponent, e.g. 123.456
%F synonym for %f
%g %e for large exponents, %f otherwise. Precision is discussed below.
%G %E for large exponents, %F otherwise
%x hexadecimal notation (with decimal power of two exponent), e.g. -0x1.23abcp+20
%X upper-case hexadecimal notation, e.g. -0X1.23ABCP+20

%f     default width, default precision
%9f    width 9, default precision
%.2f   default width, precision 2
%9.2f  width 9, precision 2
%9.f   width 9, precision 0

# String/Slice of byte
%s the uninterpreted bytes of the string or slice
%q a double-quoted string safely escaped with Go syntax
%x base 16, lower-case, two characters per byte
%X base 16, upper-case, two characters per byte

# Slice
%p address of 0th element in base 16 notation, with leading 0x

# Pointer
%p base 16 notation, with leading 0x
The %b, %d, %o, %x and %X verbs also work with pointers,
formatting the value exactly as if it were an integer.

Templates

template package - text/template - Go Packages
valyala/fasttemplate: Simple and fast template engine for Go

template package - html/template - Go Packages
a-h/templ: A language for writing HTML user interfaces in Go.

templ

Introduction | templ docs
a-h/templ: A language for writing HTML user interfaces in Go.

Introducing templ

HTTP client

http package - net/http - Go Packages
Go by Example: HTTP Client
An API client in Go — Bitfield Consulting

Req - Simple Go HTTP client with Black Magic
imroc/req: Simple Go HTTP client with Black Magic

carlmjohnson/requests: HTTP requests for Gophers

bozd4g/go-http-client: An enhanced http client for Golang

web

cosmtrek/air: ☁️ Live reload for Go apps
Using Air with Go to implement live reload - LogRocket Blog

compares Gin, Echo, Chi
Gorilla Toolkit Open Source Project Becomes Abandonware - The New Stack

RESTful routing in Go
Go actions responses
REST Servers in Go: Part 1 - standard library - Eli Bendersky's website

rheinardkorf/go-api: A collection of Go API patterns. These are useful as a reference to quickly look up a pattern that you want to implement.

codazoda/https-basic-auth-go: A template for using HTTP Basic Authentication in Go

speedwheel/awesome-go-web-frameworks: You may not need a web framework if you design a small application for yourself, but if you're going production then you definitely will need one, a good one.

Golang: 6 must-have web frameworks for the Google Go language | InfoWorld
go-bootstrap: Generates a lean and mean Go web project

swaggo/swag: Automatically generate RESTful API documentation with Swagger 2.0 for Go. supports multiple frameworks
Automatically generate RESTful API documentation in GoLang | by Santosh Shrestha | wesionaryTEAM | Medium

chi
go-chi/chi: lightweight, idiomatic and composable router for building Go HTTP services

Welcome - Fiber Express-inspired, fasthttp
gofiber/fiber: ⚡️ Express inspired web framework written in Go
gofiber/swagger: 🧬 fiber middleware to automatically generate RESTful API documentation with Swagger
Create a Restful API with Golang from scratch - DEV Community
NEW FRAMEWORK Makes Remix And NextJS Feel Slow?? Fresh by Deno is FAST - YouTube

Flamingo: Blazingly fast frontends and web apps
Flamingo Documentations
i-love-flamingo/flamingo: Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.
i-love-flamingo/swagger: Adds Swagger UI (open API) support

Echo - High performance, minimalist Go web framework HTTP/2, auto TLS
labstack/echo: High performance, minimalist Go web framework
swaggo/echo-swagger: echo middleware to automatically generate RESTful API documentation with Swagger 2.0.
pangpanglabs/echoswagger: Swagger UI generator for Echo framework

savsgio/atreugo: High performance and extensible micro web framework. Zero memory allocations in hot paths. fasthttp
Nerzal/atreugo-swagger: swagger handler for atreugo

goadesign/goa: Design-based APIs and microservices in Go

go-zero stack, API and RPC
zeromicro/go-zero: go-zero is a web and rpc framework written in Go. It's born to ensure the stability of the busy sites with resilient design. Builtin goctl greatly improves the development productivity.
熔断原理与实现 Golang 版 - InfoQ 写作平台

Getting Started | httpin Docs

valyala/fasthttp: Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
panjf2000/gnet: 🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go./ gnet 是一个高性能、轻量级、非阻塞的事件驱动 Go 网络框架。

chi routing, middleware, render and docgen

Iris

Iris Web Framework

kataras/iris: The fastest HTTP/2 Go Web Framework. New, modern and easy to learn. Fast development with Code you control. Unbeatable cost-performance ratio :rocket:
kataras/iris-cli: [WIP] Iris Command Line Interface
iris-contrib/examples: This repository contains small and practical examples for the Iris Web Framework.

Gin

Gin Web Framework
gin-gonic/gin: Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

gin package - github.com/gin-gonic/gin - Go Packages
gin-gonic/examples: A repository to host examples and tutorials for Gin.

swaggo/gin-swagger: gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
Building microservices in Go with Gin - LogRocket Blog
Simple REST service in Golang with OpenAPI spec and ORM | by Tamas Ragoncsa | Dev Genius gin, viper, gorm, gin-swagger

Gower

falling-ts/gower: Go 语言开发 Web 的一种快速启动目录,默认使用模板集成模式,非前后端分离。Go language development Web a quick start directory, the default use of template integration mode, not front-end separation.
Home - Wiki - Gitee.com

Buffalo

Buffalo - Rapid Web Development in Go
Buffalo - The Go Web Eco-System

gobuffalo/plugins
buffalo-cli/cli/internal/plugins at master · gobuffalo/buffalo-cli
swaggo/buffalo-swagger: Buffalo middleware to automatically generate RESTful API documentation with Swagger 2.0.

Goa Design

Goa :: Design first.
Goa

web scraping

antchfx/antch: Antch, a fast, powerful and extensible web crawling & scraping framework for Go 😴inactive
antchfx/antch-getstarted

antchfx/htmlquery: htmlquery is golang XPath package for HTML query.
antchfx/xpath: XPath package for Golang, supports HTML, XML, JSON document query.

bitfield/weaver: A simple link checker in Go rate limiting

CLI

Writing Friendly Command Line Applications | Gopher Academy Blog
Fun With Flags | Gopher Academy Blog
Building an Awesome CLI App in Go - OSCON 2017 - spf13.com
flag package - flag - pkg.go.dev CLI args parser
Writing Go CLIs With Just Enough Architecture · The Ethically-Trained Programmer

Cobra. Dev
spf13/cobra: A Commander for modern Go CLI interactions
spf13/viper: Go configuration with fangs
Building an Awesome CLI App in Go - OSCON 2017 - spf13.com From slide 134

gdamore/tcell: Tcell is an alternate terminal package, similar in some ways to termbox, but better in others.
marcusolsson/tui-go: A UI library for terminal applications.
rivo/tview: Rich interactive widgets for terminal-based UIs written in Go

hanslub42/rlwrap: A readline wrapper

muesli/termenv: Advanced ANSI style & color support for your terminal applications

AlecAivazis/survey: A golang library for building interactive prompts with full support for windows and posix terminals.

urfave/cli: A simple, fast, and fun package for building command line apps in Go

meowgorithm/babyenv: Go environment var parsing, for babies

Charm/Bubbletea/Bubbles

Charm
charmbracelet/charm: The Charm Tool and Library 🌟
charmbracelet/bubbles: TUI components for Bubble Tea 🍡
charmbracelet/bubbletea: A powerful little TUI framework 🏗

Charm CLI - YouTube
Charm CLI Community - YouTube
Bubble Tea Tutorials - YouTube
Cool Projects with Charm CLI - YouTube

Scripting

bitfield/script: Making it easy to write shell-like scripts in Go
Scripting with Go — Bitfield Consulting
Go 寫腳本 - 閱坊

ganbarodigital/go_scriptish: scriptish is a library to help you port bash scripts to Golang
Scriptish - Portable Shell Scripts Using Golang - YouTube

Go As a Scripting Language in Linux - YouTube gorun, binfmt_misc

GUI

GUI - Awesome Go / Golang

Fyne
Create GUI Apps with Go | Fyne Toolkit | Awesome Go - YouTube

Gio UI

Resource embedding

embed package - embed - pkg.go.dev

v0x.nl - Portable apps with Go and Next.js

A better way than “ldflags” to add a build version to your Go binaries | by Andrew Hayes | Jan, 2022 | Level Up Coding

// get_version.sh will generate version.txt
//go:generate bash get_version.sh
//go:embed version.txt
var version string
go generate
go build -v

GeertJohan/go.rice: go.rice is a Go package that makes working with resources such as html,js,css,images,templates, etc very easy.

gobuffalo/packr: The simple and easy way to embed static files into Go binaries.
Introducing Pkger — Static File Embedding in Go | by Mark Bates | Buffalo — Rapid Web Development in Go

Database/ORM

sql#ORM (or not)

Comparing database/sql, GORM, sqlx, and sqlc | The GoLand Blog

sql - The Go Programming Language
Go database/sql tutorial
go-pg/pg: Golang ORM with focus on PostgreSQL features and performance

jmoiron/sqlx: general purpose extensions to golang's database/sql SQL sanitizer

Masterminds/squirrel: Fluent SQL generation for golang

rocketlaunchr/dbq: Zero boilerplate database operations for Go

Bun: SQL client for Golang
uptrace/bun: SQL-first Golang ORM

GORM - The fantastic ORM library for Golang, aims to be developer friendly.

Working with SQLite using Go and Python

A Billion Dollar Go Mistake | Neenad Ingole | ITNEXT proper transaction

RPC

RPCX

Quick start | Go | gRPC
grpc package - google.golang.org/grpc - Go Packages

Log

Send Logs from Go to Logstash in the ELK Stack with Docker Setup - DEV Community

kataras/golog: A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.

Clipboard

golang-design/clipboard: 📋 cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)
changkun/midgard: ⛰️ Universal clipboard sharing service (supports macOS/Linux/Windows/iOS)

Installed Packages

With Docker:
Go + Docker = ♥

Learn

Official

Documentation - The Go Programming Language
The Go Programming Language Specification - The Go Programming Language
DevDocs/Go standard library

The Go Blog - The Go Programming Language
talks - The Go Programming Language

Get Started - go.dev
A Tour of Go, solutions
How to Write Go Code - The Go Programming Language
Effective Go - The Go Programming Language
Frequently Asked Questions (FAQ) - The Go Programming Language
Home · golang/go Wiki
quii/learn-go-with-tests: Learn Go with test-driven development

The How and Why of Go, Part 1: Tooling
Go Dynamic Tools

Advanced Golang - YouTube Code With Ryan

Golang University 101 - Learn Golang - YouTube
Golang UK Conference 2015 - Andrew Gerrand - Stupid Gopher Tricks - YouTube slides

Bitfield Consulting

Bitfield Consulting
bitfield (bitfield) / Repositories
Let's Code - YouTube

The Tao of Go — Bitfield Consulting
Ten commandments of Go — Bitfield Consulting
So you're ready for green belt? — Bitfield Consulting

Design

Golang map[string]struct{} can be used as a Set type where every element is unique.

Go at Google: Language Design in the Service of Software Engineering - go.dev
Analysis of the Go runtime scheduler
Scalable Go Scheduler Design Doc - Google Docs

The Why of Go - YouTube

Keeping up with the Gophers

Principles of designing Go APIs with channels - inconshreveable channels are colorless

GopherCon 2015: Andrew Gerrand - Closing Keynote - YouTube How Go was made

Data Structures

research!rsc: Go Data Structures
research!rsc: Data Structures Go Programs

Arrays, Slices and Maps in Go -Go 101

The results of reflect.DeepEqual(x, y) and x == y may be different. -Go 101

Function values are equal only if both are nil and their types are identical.

Building A Queue - Part 1
Building A Queue - Part 2
Building A Queue - Part 3
Building A Queue - Part 4

new() and make()

allocation - Effective Go - The Go Programming Language

new(T) allocates zeroed storage for a new item of type T and returns its address, a value of type *T
Convension of func newFile(path str) *File can be used for constructor
make(T, args) creates slices, maps, and channels only, and it returns an initialized (not zeroed) value of type T (not *T).

Array/Slices

Arrays, slices (and strings): The mechanics of 'append' - go.dev
Go Slices: usage and internals - go.dev

Maps

Go maps in action - go.dev

Maps -Go 101

map — Go — Bitfield Consulting
Go maps FAQ — Bitfield Consulting

dictionary - Computing the memory footprint (or byte length) of a map - Stack Overflow 2015

Struct

Structs in Go -Go 101

type S = struct {
 X byte
 _ [7]byte  // blank field for padding
 Y int32
}

Videos

The Go Programming Language - YouTube Rob Pike 2009
Go Programming - YouTube
Go Language Programming Practical Basics Tutorial - YouTube
Go Programming Language Tutorials - Todd McLeod - YouTube
Writing, building, installing, and testing Go code - YouTube
Google I/O 2011: Writing Web Apps in Go - YouTube
Learn Go Programming by Building 11 Projects – Full Course - YouTube 8:24:39

ProgrammingPercy - YouTube
samvcodes - YouTube

Anthony GG - YouTube
How To Golang - YouTube

GopherCon Europe - YouTube
Gopher Academy - YouTube
Golang Dojo - YouTube

Playground

Go Playground - The Go Programming Language
Introducing the Go Playground - The Go Programming Language
Inside the Go Playground - go.dev

Better Go Playground

DevBits Playground

Whitepaper

collection of whitepaper-ish articles in Go Blog

Article index - go.dev
Text normalization in Go - go.dev
Strings, bytes, runes and characters in Go - go.dev
Gobs of data - go.dev
JSON and Go - go.dev
Go's Declaration Syntax - go.dev

Book

Books · golang/go Wiki · GitHub

dariubs/GoBooks: List of Golang books
stormtrooper96/books

Go Bootcamp | Softcover.io ❗!important, concise, reference to official doc
Go 101 - Go 101: an online Go programming book + knowledge base ❗!important
An Introduction to Programming in Go | Go Resources
Introducing Go -O'Reilly Media
The Little Go Book
karlseguin/the-little-go-book
The Go Handbook

开源图书在线阅读 - Go 语言中文网 - Golang 中文社区

Third party

10 Free Resources To Learn Go Programming Language
The Top 10 Places to Learn Go - DEV Community 👩‍💻👨‍💻
Golang Tutorial Guide - A List of Free Courses to Learn the Go Programming Language
cdarwin/go-koans: koans for go
Aniket762/namaste-go: A repository to learn the basics of Go Programming.
Golang-challenge - We offers the best mobile tutorials for android and ios devices.
Gophercises - Coding exercises for budding gophers
Golang examples and solutions from different packages of the standard library. - golangprograms.com
Go · How I Start.

ProgrammingPercy
Go by Example
Golang Advanced Tutorial - Welcome To Golang By Example
Go 101 -Go 101
Learn Go in Y Minutes
GoLang Tutorials
Go on Exercism
GopherCasts
Home - Practical Go Lessons Book
Gopher Academy Blog
Go (Golang) Programming Blog - Ardan Labs
Learn Go Programming: A Tutorial with Code Examples | Toptal
Go Language Patterns
Go go-to guide · YourBasic
Golang tutorial: Table Of Contents
Go Code Tutorials by Envato Tuts+
Getting started with Go for frontend developers - LogRocket Blog
Practical Go | Dave Cheney
Let's Eat GO ! 實務開發雜談 by Golang :: 第 11 屆 iThome 鐵人賽
golang snippets

Applied Go · Applied Go
Programming with Google Go | Coursera

aodin/golang-for-pythonistas: Advanced topics for Python programmers looking to use Go

Golang for JavaScript developers - Part 1 - DEV Community 👩‍💻👨‍💻
Golang for JavaScript developers - Part 2 - DEV Community 👩‍💻👨‍💻

mholt/meetupchat: Simple chat using TCP, as a quick workshop for beginner (Go) programmers
Go | Dave Cheney
Go (Golang) Programming Blog - Ardan Labs
Golang Development | TutorialEdge.net

Project Structure

How I Structure New Projects In Golang - YouTube
This Is The BEST Way To Structure Your GO Projects - YouTube
Hexagonal Architecture In Golang!? - Full Structure Example - YouTube
How To Structure Domain Driven Design (DDD) In Go - YouTube
How To Structure Your Go App - Full Course [ Hex Arch + Tests ] - YouTube 2:45:05

Internals

src/ - go.dev

Scheduling In Go : Part I - OS Scheduler
Scheduling In Go : Part II - Go Scheduler
Scheduling In Go : Part III - Concurrency

defer

research!rsc: Broken abstractions in Go go and defer implementation
Demystifying 'defer' — Bitfield Consulting
Don't defer Close() on writable files – joe shaw

==

How == works?

var a, b interface{} = []int{1, 2}, []int{1, 2}
fmt.Println(reflect.DeepEqual(a, b)) // true
fmt.Println(a == b)                  // panic

x == y will panic if the two operands are both interface values and their dynamic types are identical and incomparable.

var s2 = "abc"[0:0]
fmt.Println(s2 == "") // true
fmt.Println(*(*uintptr)(unsafe.Pointer(&s2))) // 4869856
fmt.Println(s1 == s2) // true
func returnsError() error {
 var p *MyError = nil
 if bad() {
  p = ErrBad
 }
 return p // Will always return a non-nil error.
}

Following types don't support comparisons:

Types which don't support comparisons can't be used as the key type of map types.

Please note,

On why slice, map and function types don't support comparison, please read this answer in the official Go FAQ.

Memory

The Go Memory Model - The Go Programming Language
research!rsc: Memory Models
go 内存管理 | 李乾坤的博客
Memory Layouts -Go 101
Memory Blocks -Go 101
A visual guide to Go Memory Allocator from scratch (Golang) | by Ankur Anand | Medium
🚀 Visualizing memory management in Golang | Technorage

Garbage Collection

Getting to Go: The Journey of Go's Garbage Collector - go.dev
Go GC: Prioritizing low latency and simplicity - go.dev
A Guide to the Go Garbage Collector - The Go Programming Language 1.19
Go’s march to low-latency GC — Twitch Blog

Garbage Collection In Go : Part I - Semantics
Garbage Collection In Go : Part II - GC Traces
Garbage Collection In Go : Part III - GC Pacing

Manual Memory Management in Go using jemalloc - Dgraph Blog

Receivers

Methods - Effective Go - The Go Programming Language
Should I define methods on values or pointers? - The Go Programming Language

Neither self nor this: Receivers in Go | Heroku
Don't Get Bitten by Pointer vs Non-Pointer Method Receivers in Golang | I care, I share, I'm Nathan LeClaire.

Concurrency

learn-to-code#Concurrency and Parallelism

Concurrency is not parallelism - go.dev
Advanced Go Concurrency Patterns - go.dev
Go Concurrency Patterns: Pipelines and cancellation - go.dev
Go Concurrency Patterns: Timing out, moving on - go.dev

Concurrency is not Parallelism by Rob Pike - YouTube slides
Go: code that grows with grace on Vimeo slides using channels for chat, copy interface, matcher
Google I/O 2012 - Go Concurrency Patterns - YouTube slides
Google I/O 2013 - Advanced Go Concurrency Patterns - YouTube slide
Concurrency Patterns In Go - YouTube
Master Go Programming With These Concurrency Patterns (in 40 minutes) - YouTube 46:14
Concurrency Made Easy (Practical Tips For Effective Concurrency In Go) - YouTube
dotgo applied concurrency in go
On using Go channels like Python generators · The Ethically-Trained Programmer
Locks versus channels in concurrent Go | Opensource.com

use chan struct{} to signify that this is a channel for event/signal

Curious Channels | Dave Cheney
Channel Axioms | Dave Cheney

Go Concurrency from the Ground Up | doxsey.net
Visualizing Concurrency in Go · divan's blog
Goroutine IDs · Scott Mansfield
Share Memory By Communicating - go.dev
Codewalk: Share Memory By Communicating - go.dev
Share memory by communicating · The Ethically-Trained Programmer

The Behavior Of Channels
Goroutine Leaks - The Forgotten Sender
Goroutine Leaks - The Abandoned Receivers
Concurrency Trap #2: Incomplete Work

An Intro to Concurrency Patterns in Go - via @codeship | via @codeship
Concurrency in Go Part II - via @codeship | via @codeship
Patterns for scalable web services in Go

Go Microservices blog series, part 1. | Callista Enterprise

go - Multiple goroutines listening on one channel - Stack Overflow
rheinardkorf/go-concurrency: A collection of Go concurrency patterns. These are useful as a reference to quickly look up a pattern that you want to implement.

Introduction to Go - let's build a network application! | Go User Group Berlin
Directional Channels in Go | Gopher Academy Blog

WaitGroup

Go by Example: WaitGroups
Concurrency patterns in Golang: WaitGroups and Goroutines - LogRocket Blog

  1. create WaitGroup
  2. add when creating Goroutine
  3. done when Goroutine exists
  4. wait on caller for Goroutines to finish

Context

context package - context - pkg.go.dev

Go Concurrency Patterns: Context - go.dev
Context Package Semantics In Go

Context is for cancelation | Dave Cheney
Context isn’t for cancellation | Dave Cheney

Data Race

Introducing the Go Race Detector - go.dev
Data races explained · YourBasic Go
Data races in Go(Golang) and how to fix them
Wednesday pop quiz: spot the race | Dave Cheney
谈谈 Golang 中的 Data Race - poslua | ms2008 Blog

Date time

time package - time - pkg.go.dev
time package - Duration - pkg.go.dev

Use reference time (2006-01-02T15:04:05Z07:00) to define layout
src/time/format.go - The Go Programming Language

Time Conversion in Go (Golang) - Welcome To Golang By Example

regex

regex#Go

Typing/Reflection

Go Type System Overview -Go 101
Value Conversion, Assignment and Comparison Rules in Go -Go 101

Everything You Always Wanted to Know About Type Inference - And a Little Bit More - The Go Programming Language

var x any
//...
// note: there's no `fallthrough` in type swtich
switch i := x.(type) {
case int:
    fmt.Printf("x is an integer: %d\n", i)
case string:
    fmt.Printf("x is a string: %q\n", i)
case nil:
    fmt.Println("x is nil")
default:
    fmt.Println("x is some other type")
}

reflect package - reflect - pkg.go.dev
Effective Go - go.dev Type switch/guard with type T.(type)
The Laws of Reflection - go.dev
A GIF decoder: an exercise in Go interfaces - go.dev

research!rsc: Go Data Structures: Interfaces
How to use interfaces in Go - jordan orelli
Reflection in Go: Use cases and tutorial - LogRocket Blog
reflection - How get pointer of struct's member from interface{} - Stack Overflow

Under the covers, interfaces are implemented as two elements, a type T and a value V.
An interface value is nil only if the V and T are both unset, (T=nil, V is not set), In particular, a nil interface will always hold a nil type. If we store a nil pointer of type *int inside an interface value, the inner type will be *int regardless of the value of the pointer: (T=*int, V=nil). Such an interface value will therefore be non-nil even when the pointer value V inside is nil.

var r io.Reader
tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
r = tty

var w io.Writer
w = r.(io.Writer)  // type assertion

Type assertion is applicable to interface when you know the concrete type.
Type assertion is performed at runtime.
Effective Go - go.dev
go - What is the difference between type conversion and type assertion? - Stack Overflow
Type Assertions vs Type Conversions in Golang

Pointer

Don't fear the pointer — Bitfield Consulting

// `unsafe.Pointer` for casting
x := 12
p := unsafe.Pointer(&x)
y := (*float64)(p)
fmt.Printf("%T\n", y)
// *float64

Generics

generics landed in Go 1.18 in 2022-03

Why Generics? - The Go Programming Language
An Introduction To Generics - The Go Programming Language
Tutorial: Getting started with generics - The Go Programming Language

Generics can make your Go code slower
On Go's Generics Implementation and Performance

samber/lo: 💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)

spec: add generic programming using type parameters · Issue #43651 · golang/go
Type Parameters Proposal

[ generics] Moving forward with the generics design draft
Generics and parentheses
Summary of Go Generics Discussions

Go Generics 101 -Go 101
Generics in Go Explained with Code Examples

Type parameters in Go — Bitfield Consulting
Generics in Go — Bitfield Consulting
Functional programming in Go — Bitfield Consulting
A generic Set type in Go — Bitfield Consulting

Generics Part 01: Basic Syntax
Generics Part 02: Underlying Types
Generics Part 03: Struct Types and Data Semantics

Who needs generics? Use ... instead! · Applied Go

What’s New in Go 1.20, Part I: Language Changes · The Ethically-Trained Programmer fix comparable type

Advanced Golang: Generics Explained - YouTube

Decorators

Go 语言的修饰器编程 | | 酷 壳 - CoolShell

Testing

# skip test cache
go test -count=1

testing package - testing - Go Packages

Testing and Test-Driven-Development in Snap — Intel SDI — Medium
Testing and Test Driven Development in Snap (Part 2) — Intel SDI — Medium

Getting Started In Testing Your Go Application | Toptal

Go Testing with Test Driven Development - DEV Community
Writing table driven tests in Go | Dave Cheney

An Introduction to Testing in Go | TutorialEdge.net
Advanced Go Testing Tutorial | TutorialEdge.net
Improving Your Go Tests and Mocks With Testify | TutorialEdge.net

Integration Testing in Go: Part I - Executing Tests with Docker
Integration Testing in Go: Part II - Set-up and Writing Tests
george-e-shaw-iv/integration-tests-example: An example project showcasing how Ardan Labs writes integration tests

astubbs/testdox: TestDox creates simple documentation from the method names in JUnit test cases.
bitfield/gotestdox: Show Go test results as readable sentences

Test-driven development with Go — Bitfield Consulting
Random testing in Go — Bitfield Consulting
Fuzz tests in Go — Bitfield Consulting
Writing a Go fuzz target — Bitfield Consulting

testscript

testscript package - github.com/rogpeppe/go-internal/testscript - Go Packages
Test scripts in Go — Bitfield Consulting series

Tips and Tricks

The Zen of Go
The Zen of Go / Dave Cheney - YouTube
The Zen of Go with Dave Cheney (Go Time #122) |> Changelog

Golang UK Conference 2016 - Mat Ryer - Idiomatic Go Tricks - YouTube

Go Proverbs
Go Proverbs - Rob Pike - Gopherfest - November 18, 2015 - YouTube

Organizing Go code - go.dev
Go best practices, six years in
Golang 新手开发需要注意的七个细节 |虞双齐的博客
when nil is not nil - spf13.com
7 common mistakes in Go (2015) - spf13.com
★ Ultimate Visual Guide to Go Enums ★ - Learn Go Programming
Trying Clean Architecture on Golang - Hacker Noon
The ultimate guide to writing a Go tool · Fatih Arslan

Go FAQ 101 - Go 101: an online Go programming book + knowledge base
Go Tips 101 -Go 101
Go Details 101 -Go 101
Go Details & Tips 101 -Go 101

The Top 10 Most Common Mistakes I’ve Seen in Go Projects
The part that passing 0.3KB data by value is faster than by reference is surprising

Lessons learned from programming in Go | Opensource.com
7 common mistakes in Go and when to avoid them by Steve Francia (Docker) - YouTube

One to use context with an io.Reader or io.Writer. Cancellable io.Reader example
io package - io - pkg.go.dev
io package - io - pkg.go.dev

Versioning

gopkg.in - Stable APIs for the Go language

Docker

Docker Images : Part I - Reducing Image Size

Building a Golang Docker image — Bitfield Consulting

FROM golang:1.20-alpine AS build

WORKDIR /src/
COPY main.go go.* /src/
RUN CGO_ENABLED=0 go build -o /bin/demo

FROM scratch
COPY --from=build /bin/demo /bin/demo
ENTRYPOINT ["/bin/demo"]

Handling Errors

pkg/errors: Simple error handling primitives

Errors are values - go.dev Error handling does not obscure the flow of control.
Error handling and Go - go.dev
Defer, Panic, and Recover - go.dev
Working with Errors in Go 1.13 - go.dev error wrapping
How to compare Go errors - Stack Overflow
Go: Creating Custom Error Wrapper and Do Proper Error Equality Check - DEV Community
Comparing error or error equality in Go (Golang) - Welcome To Golang By Example error wrapping
How to get stacktraces from errors in Golang with go-errors/errors | Bugsnag Blog
Creating Domain Specific Error Helpers in Go With errors.As · The Ethically-Trained Programmer

Testing errors in Go — Bitfield Consulting
Comparing Go error values — Bitfield Consulting
Error wrapping in Go — Bitfield Consulting

Handling errors LIKE a 10x ENGINEER in Golang - Golang Service Pattern - YouTube

Creating Domain Specific Error Helpers in Go With errors.As · The Ethically-Trained Programmer
Mastering Your Error Domain · The Ethically-Trained Programmer

// error wrapping
func Open(path string) (*DB, error) {
 db, err := bolt.Open(path, 0600, &bolt.Options{Timeout: 1 * time.Second})
 if err != nil {
  return nil, fmt.Errorf("opening bolt db: %w", err)
 }
 return &DB{db}, nil
}

Use error.Is() since Go 1.13 (2019-09)

_, err := os.Stat("a-nonexistent-file.abcxyz")
fmt.Println(errors.Is(err, os.ErrNotExist)) // true
fmt.Println(err == os.ErrNotExist) // false
// akin to catch for the function context
defer func() {
 if err := recover(); err != nil {
  fmt.Println("Error:", err)
  log.Println("stacktrace from panic: \n" + string(debug.Stack()))
 }
}()

Debugging

go-delve/delve: Delve is a debugger for the Go programming language.
Stop debugging Go with Println and use Delve instead | Opensource.com

Visualization

hirokidaichi/goviz: a visualization tool for golang project dependency
TrueFurby/go-callvis: Visualize call graph of your Go program using dot format.

#perfmatters

Profiling Go Programs - go.dev
GopherCon 2019: Dave Cheney - Two Go Programs, Three Different Profiling Techniques - YouTube
Profiling and Optimizing Go - YouTube

Profiling Go programs with pprof
Go Performance Case Studies | DoltHub Blog

Go Optimizations 101 -Go 101

Nitro : A quick and simple profiler for golang - spf13.com
profefe/profefe: Continuously collect profiling data for long-term postmortem analysis

Profile-guided optimization - The Go Programming Language use -pgo=auto compiler option and default.pgo file