Build Docker Images
Use Go linker to strip debugging information from the binary¶
Reduce Docker image size by using Go linker to strip debugging information Dwarf from the binary.
go build -ldflags='-s' -o ./bin/ ./cmd/api
Go Build and Cache¶
go build will build the image for the host operating system and architecture. Build for various operating systems and arch systems using build flags
go tool list
GOOS=linux GOARCH=amd64 go build -o /bin/ ./cmd/foo
View the cache path go env GOCACHE
go build -a -o /bin/
go clean -cache