go build
Compile Go sources. More information: https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies.
-
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}}
-
Compile a main package into an executable, enabling data race detection:
go build -race -o {{path/to/executable}} {{path/to/main/package}}
License and Disclaimer
The content on this page is copyright © 2014—present the tldr-pages team and contributors.This page is used with permission under Creative Commons Attribution 4.0 International License.
While we do attempt to make sure content is accurate, there isn't a warranty of any kind.