Golang -- Getting started
Build
Follow this guild to build golang from source.
1
2
3
4
cd src && ./all.bash
# If you do not want to run tests, then
./make.bash
Also, remember to clear cache go clean --cache after rebuilding go, or use -a argument when running go build.
Go tools
go fmt ./...formats go code.golangci-lintis the most used linter for Golang.- deadcode detector
Debug
go mod edit -replace is the way to go to use a customized branch or commit of a dependence.
delve
dlv attach pid is a useful command to see the internals of a running process. Under the hood, delve calls Unix system call ptrace. Inside Alpine
1
2
3
apk add --update --no-cache go
go install github.com/go-delve/delve/cmd/dlv@latest
export PATH=$PATH:/root/go/bin
Not sure why using alpine, delve cannot find the debug symbols.
This post is licensed under CC BY 4.0 by the author.