golang
Options for Golang support.
Backend: pants.backend.experimental.go
Config section: [golang]
Basic options
go_search_paths
--golang-go-search-paths="['<str>', '<str>', ...]"
PANTS_GOLANG_GO_SEARCH_PATHS
[golang]
go_search_paths = [
'<str>',
'<str>',
...,
]
[ "<PATH>" ]
A list of paths to search for Go.
Specify absolute paths to directories with the go
binary, e.g. /usr/bin
. Earlier entries will be searched first.
The special string "<PATH>"
will expand to the contents of the PATH env var.
minimum_expected_version
--golang-minimum-expected-version=<str>
PANTS_GOLANG_MINIMUM_EXPECTED_VERSION
[golang]
minimum_expected_version = <str>
1.17
The minimum Go version the distribution discovered by Pants must support.
For example, if you set '1.17'
, then Pants will look for a Go binary that is 1.17+, e.g. 1.17 or 1.18.
You should still set the Go version for each module in your go.mod
with the go
directive.
Do not include the patch version.
Advanced options
subprocess_env_vars
--golang-subprocess-env-vars="['<str>', '<str>', ...]"
PANTS_GOLANG_SUBPROCESS_ENV_VARS
[golang]
subprocess_env_vars = [
'<str>',
'<str>',
...,
]
[ "LANG", "LC_CTYPE", "LC_ALL", "PATH" ]
Environment variables to set when invoking the go
tool. Entries are either strings in the form ENV_VAR=value
to set an explicit value; or just ENV_VAR
to copy the value from Pants's own environment.
tailor_binary_targets
--[no-]golang-tailor-binary-targets
PANTS_GOLANG_TAILOR_BINARY_TARGETS
[golang]
tailor_binary_targets = <bool>
True
If true, add a go_binary
target with the tailor
goal in every directory with a .go
file with package main
.
tailor_go_mod_targets
--[no-]golang-tailor-go-mod-targets
PANTS_GOLANG_TAILOR_GO_MOD_TARGETS
[golang]
tailor_go_mod_targets = <bool>
True
If true, add a go_mod
target with the tailor
goal wherever there is a go.mod
file.
tailor_package_targets
--[no-]golang-tailor-package-targets
PANTS_GOLANG_TAILOR_PACKAGE_TARGETS
[golang]
tailor_package_targets = <bool>
True
If true, add a go_package
target with the tailor
goal in every directory with a .go
file.
Deprecated options
expected_version
--golang-expected-version=<str>
PANTS_GOLANG_EXPECTED_VERSION
[golang]
expected_version = <str>
1.17
Deprecated, will be removed in version: 2.14.0.dev0.
Use `[golang].minimum_expected_version` instead, which is more flexible. Pants will now work if your local Go binary is newer than the expected minimum version; e.g. Go 1.18 works with the version set to `1.17`.
The Go version you are using, such as 1.17
.
Pants will only use Go distributions from --go-search-paths
that have the expected version, and it will error if none are found.
Do not include the patch version.
Related subsystems
None