Go is a [[BSD-3]] licensed programming language which is self-hosting and originally written on the [[Plan9]] development toolchain.
- [Website](https://go.dev/)
- [Github](https://github.com/golang/go)
- [Documentation](https://go.dev/doc/)
# Notability
I use a lot of tools built in [[Go]], have written major applications in it, and have managed teams that develop with it.
```dataview
TABLE
WHERE contains(proglang, "[[Go]]")
SORT name DESC
```
# Philosophy
It is a language which exposes a minimal layer to the programmer, but hides a lot of complexity. That often is not a positive thing.
# OS Support
- [[Linux]]
- [[MacOS]]
- [[Windows]]
# Features
## Misc
A low level analysis of the calling convention in Go, including stack unwinding in panics:
https://dr-knz.net/go-calling-convention-x86-64.html
Useful Golang features:
https://husobee.github.io/golang/compile/time/variables/2015/12/03/compile-time-const.html
Golang binary size troubleshooter:
https://github.com/jondot/goweight
## Defer
https://www.joeshaw.org/dont-defer-close-on-writable-files/
# Tips
## TinyGo
- https://tinygo.org/
- https://github.com/tinygo-org/tinygo
An implementation of Go which produces binaries that can be 1% the size of the ones that the Go compiler generates.
## Always use Musl
Go itself does not need [[libc]] at all, but some *packages* do. In order to maintain Go's static compilation dreams, we need to use [[musl]] instead.
- https://honnef.co/articles/statically-compiled-go-programs-always-even-with-cgo-using-musl/
## Update Programs Installed with Go Get
Utterly bizarrely, Go will allow you to install arbitrary Go programs with `go install url` but provides no way to update them once installed.
One possible solution is to go through all of the subdirectories of `$GOPATH` and update them, but some of those will be libraries installed with `go get` which you probably don't want to update.
Install `gup`:
```sh
go install github.com/nao1215/gup@latest
```
Update all binaries installed with `go install`:
```sh
gup update
```
From looking at `gup`'s source code, it seems that it is extracting the package info from the binaries in `$GOPATH/bin` and building a command to update them one at a time. This shit is *ridiculous*.
## Cleanup Unneeded Go Packages
Not possible. lol
The only thing you can do is blow away your entire `$GOPATH` and rebuild any projects or reinstall any programs.