Golang: Tips and Notes
• Mark Eschbach
Notes while factoring code and verifying things.
Updating all dependencies for a module
Helpful for dusting a project off.
$ go get -u ./...
$ go mod tidy
$ go test ./... # good idea to ensure new deps did not break things
Golang Doc: Deprecating things
Godoc can note deprecation. JetBrains projects pickup and note these in the IDE. Example:
//Filter returns a subset of elements for each test which is true
//Deprecated: use golang.org/x/exp instead.
func Filter[E any](elements []E, test func(e E) bool) []E {
out := make([]E, 0)
for _, e := range elements {
if test(e) {
out = append(out, e)
}
}
return out
}