Skip to main content
Version: 2.14 (deprecated)

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
pants.toml
[golang]
go_search_paths = [
'<str>',
'<str>',
...,
]
default:
[
  "<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 following special strings are supported:

  • <PATH>, the contents of the PATH environment variable
  • <ASDF>, all Go versions currently configured by ASDF (asdf shell, ${HOME}/.tool-versions), with a fallback to all installed versions
  • <ASDF_LOCAL>, the ASDF interpreter with the version in BUILD_ROOT/.tool-versions

minimum_expected_version

--golang-minimum-expected-version=<str>
PANTS_GOLANG_MINIMUM_EXPECTED_VERSION
pants.toml
[golang]
minimum_expected_version = <str>
default: 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

asdf_bin_relpath

--golang-asdf-bin-relpath=<str>
PANTS_GOLANG_ASDF_BIN_RELPATH
pants.toml
[golang]
asdf_bin_relpath = <str>
default: bin

The path relative to an ASDF install directory to use to find the bin directory within an installed Go distribution. The default value for this option works for the go-sdk ASDF plugin. Other ASDF plugins that install Go may have a different relative path to use.

asdf_tool_name

--golang-asdf-tool-name=<str>
PANTS_GOLANG_ASDF_TOOL_NAME
pants.toml
[golang]
asdf_tool_name = <str>
default: go-sdk

The ASDF tool name to use when searching for installed Go distributions using the ASDF tool manager (https://asdf-vm.com/). The default value for this option is for the go-sdk ASDF plugin (https://github.com/yacchi/asdf-go-sdk.git). There are other plugins. If you wish to use one of them, then set this option to the ASDF tool name under which that other plugin was installed into ASDF.

subprocess_env_vars

--golang-subprocess-env-vars="['<str>', '<str>', ...]"
PANTS_GOLANG_SUBPROCESS_ENV_VARS
pants.toml
[golang]
subprocess_env_vars = [
'<str>',
'<str>',
...,
]
default:
[
  "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
pants.toml
[golang]
tailor_binary_targets = <bool>
default: 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
pants.toml
[golang]
tailor_go_mod_targets = <bool>
default: 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
pants.toml
[golang]
tailor_package_targets = <bool>
default: True

If true, add a go_package target with the tailor goal in every directory with a .go file.

Deprecated options

None

None