HomeDocs
DocsCommunityTestimonialsUsersGitHubTwitterBlogJobsTermsPrivacyCookies
TermsPrivacyCookies
Hey! These docs are for version 2.14, which is no longer officially supported. Click here for the latest version, 2.17!

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

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

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

subprocess_env_vars

--golang-subprocess-env-vars="['<str>', '<str>', ...]"

PANTS_GOLANG_SUBPROCESS_ENV_VARS

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_go_mod_targets

--[no-]golang-tailor-go-mod-targets

PANTS_GOLANG_TAILOR_GO_MOD_TARGETS

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

default: True

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


tailor_binary_targets

--[no-]golang-tailor-binary-targets

PANTS_GOLANG_TAILOR_BINARY_TARGETS

default: True

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


asdf_tool_name

--golang-asdf-tool-name=<str>

PANTS_GOLANG_ASDF_TOOL_NAME

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.


asdf_bin_relpath

--golang-asdf-bin-relpath=<str>

PANTS_GOLANG_ASDF_BIN_RELPATH

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.


Deprecated options

None