tldr/pages/common/go-build.md

21 lines
557 B
Markdown
Raw Normal View History

# go build
> Compile Go sources.
> More information: <https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies>.
2022-01-02 04:30:56 +00:00
- Compile a 'package main' file (output will be the filename without extension):
`go build {{path/to/main.go}}`
- Compile, specifying the output filename:
`go build -o {{path/to/binary}} {{path/to/source.go}}`
- Compile a package:
`go build -o {{path/to/binary}} {{path/to/package}}`
2022-01-02 04:30:56 +00:00
- Compile a main package into an executable, enabling data race detection:
`go build -race -o {{path/to/executable}} {{path/to/main/package}}`