https://github.com/nikolaydubina/go-recipes
go mod graph | modgraphviz | dot -Tsvg -o mod-graph.svg
Requires:
https://graphviz.org/download/
go install golang.org/x/exp/cmd/modgraphviz@latest
go list -deps -json ./... | jq -rc 'select(.Standard!=true and .Module.GoVersion!=null) | [.Module.GoVersion,.Module.Path] | join(" ")' | sort -V | uniq
go list -u -m $(go list -m -f '{{.Indirect}} {{.}}' all | grep '^false' | cut -d ' ' -f2) | grep '\['
https://eli.thegreenplace.net/2024/locally-patching-dependencies-in-go
# clone your dependency to $DEP folder
# make changes
go mod edit -replace github.com/google/go-cmp=$DEP
https://github.com/orsinium-labs/enum
type Color enum.Member[string]
var (
Red = Color{"red"}
Green = Color{"green"}
Blue = Color{"blue"}
Colors = enum.New(Red, Green, Blue)
)You can pass metadata through compiler to your binary. This is useful for including things like git commit, database schema version, integrity hashes. Variables can only be strings.
go build -v -ldflags="-X 'main.Version=v1.0.0'"
go build -v -ldflags="-X 'my/pkg/here.Variable=some-string'"
package main
var Version string
func main() {
// Version here has some value
...
}https://github.com/arl/statsviz
https://github.com/uber-go/nilaway