go

My Note

  • 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=.