- Execute long command line command
go
// os/exec
cmd, _ := exec.Command("/bin/sh", "-c", "git config --list | sed -n '/user.name/p' | cut -c 11-").Output()
- Go mod
bash
# Create package
go mod init github.com/kadekillary/example-package
# Clean up
go mod tidy
# Vendor dependencies
go mod vendor
# Install package
go get github.com/kadekillary/example-package
# Remove modules
go clean --modcache
- Go build
bash
# go build [-o output] [build flags] [packages]
# multiple go files -> one dir
go build *.go
# using build tags
# https://www.digitalocean.com/community/tutorials/customizing-go-binaries-with-build-tags
- Test Options
bash
# Test for race conditions
go test -race
# Benchmark
go test -bench=.