Go tool link
Jump to navigation
Jump to search
External
Internal
Overview
The linker is typically invoked as go tool link
or as part of the go build
command. It reads the Go archive or object for a package main
, along with its dependencies, and combines them into an executable binary.
Options
When invoked by go build
, all of the following options can be passed from go build
command line with the -ldflags
option. For syntax, see:
-X importpath.name=value
Set the value of the string variable in import path named name to value. This option is only effective if the variable is declared in the source code either uninitialized or initialized to a constant string expression. -X
will not work if the initializer makes a function call or refers to other variables.
go tool link -X 'example.com/myapp/internal/version.Version=1.2.0' [...]