| name | go |
| description | Go toolchain commands - build, test, modules, and more |
| argument-hint | [command or question] |
| allowed-tools | Bash, Read, Glob, Grep |
Help with Go tooling based on $ARGUMENTS.
Module Management
go mod init github.com/user/project
go get github.com/pkg/errors
go get github.com/pkg/errors@v0.9.1
go get github.com/pkg/errors@latest
go mod tidy
go mod download
go mod vendor
go mod graph
go mod why github.com/pkg/errors
Building
go build
go build ./cmd/myapp
go build -o bin/myapp ./cmd/myapp
GOOS=linux GOARCH=amd64 go build -o bin/myapp-linux
go build -ldflags "-X main.version=1.0.0"
go install ./cmd/myapp
Testing
go test ./...
go test -v ./...
go test -run TestName ./...
go test -cover ./...
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
go test -race ./...
go test -bench=. ./...
go test -bench=BenchmarkName -benchmem ./...
Code Quality
go fmt ./...
gofmt -s -w .
go vet ./...
go generate ./...
Other Commands
go run main.go
go run ./cmd/myapp
go list ./...
go list -m all
go doc fmt.Println
go doc -all fmt
go env
go env GOPATH
go env -w GOPROXY=https://proxy.golang.org,direct
Cross-Compilation Targets
| GOOS | GOARCH |
|---|
| linux | amd64, arm64, arm |
| darwin | amd64, arm64 |
| windows | amd64, arm64 |
| freebsd | amd64 |