go build [packages...]

Compile packages and dependencies

Arguments

NameDescription
packagesfilepaths

Options

NameDescription
-nPrint the commands but do not run them
-vPrint the names of packages as they are compiled
-xPrint the commands
-tags <tags>A comma-separated list of build tags to consider satisfied during the build
-toolexec <cmd>A program to use to invoke toolchain programs like vet and asm
-aForce rebuilding of packages that are already up-to-date
-p <programs>The number of programs, such as build commands or
-raceEnable data race detection. Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64, linux/ppc64le and linux/arm64 (only for 48-bit VMA)
-msanEnable interoperation with memory sanitizer. Supported only on linux/amd64, linux/arm64 and only with Clang/LLVM as the host C compiler. On linux/arm64, pie build mode will be used
-workPrint the name of the temporary work directory and do not delete it when exiting
-asmflags <flag...>Arguments to pass on each go tool asm invocation
-buildmode <mode>Build mode to use. See 'go help buildmode' for more
-compiler <name>Name of compiler to use, as in runtime.Compiler (gccgo or gc)
-gccgoflags <flag...>Arguments to pass on each gccgo compiler/linker invocation
-gcflags <flag...>Arguments to pass on each go tool compile invocation
-installsuffix <suffix>A suffix to use in the name of the package installation directory,
-ldflags <flag...>Arguments to pass on each go tool link invocation
-linksharedBuild code that will be linked against shared libraries previously
-mod <mode>Module download mode to use: readonly, vendor, or mod
-modcacherwLeave newly-created directories in the module cache read-write
-modfile <file>In module aware mode, read (and possibly write) an alternate go.mod file instead of the one in the module root directory
-overlay <file>Read a JSON config file that provides an overlay for build operations
-pkgdir <dir>Install and load all packages from dir instead of the usual locations
-trimpathRemove all file system paths from the resulting executable
-o <arg>Write the resulting executable or object to the named output file or directory
-iInstall the packages that are dependencies of the target