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: <span style="color: purple"><code>pants.backend.experimental.go</code></span> Config section: <span style="color: purple"><code>[golang]</code></span>

## Basic options

<div style="color: purple">

### `go_search_paths`

<code>--golang-go-search-paths="['&lt;str&gt;', '&lt;str&gt;', ...]"</code><br> <code>PANTS_GOLANG_GO_SEARCH_PATHS</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <pre>[ "&lt;PATH&gt;" ]</pre></span>

<br>

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

    </div> <br>

<div style="color: purple">

### `minimum_expected_version`

<code>--golang-minimum-expected-version=<str></code><br> <code>PANTS_GOLANG_MINIMUM_EXPECTED_VERSION</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>1.17</code></span>

<br>

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.

</div> <br>

## Advanced options

<div style="color: purple">

### `subprocess_env_vars`

<code>--golang-subprocess-env-vars="['&lt;str&gt;', '&lt;str&gt;', ...]"</code><br> <code>PANTS_GOLANG_SUBPROCESS_ENV_VARS</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <pre>[ "LANG", "LC&lowbar;CTYPE", "LC&lowbar;ALL", "PATH" ]</pre></span>

<br>

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.

</div> <br>

<div style="color: purple">

### `tailor_go_mod_targets`

<code>--[no-]golang-tailor-go-mod-targets</code><br> <code>PANTS_GOLANG_TAILOR_GO_MOD_TARGETS</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>True</code></span>

<br>

If true, add a `go_mod` target with the `tailor` goal wherever there is a `go.mod` file.

</div> <br>

<div style="color: purple">

### `tailor_package_targets`

<code>--[no-]golang-tailor-package-targets</code><br> <code>PANTS_GOLANG_TAILOR_PACKAGE_TARGETS</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>True</code></span>

<br>

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

</div> <br>

<div style="color: purple">

### `tailor_binary_targets`

<code>--[no-]golang-tailor-binary-targets</code><br> <code>PANTS_GOLANG_TAILOR_BINARY_TARGETS</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>True</code></span>

<br>

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

</div> <br>

<div style="color: purple">

### `asdf_tool_name`

<code>--golang-asdf-tool-name=<str></code><br> <code>PANTS_GOLANG_ASDF_TOOL_NAME</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>go-sdk</code></span>

<br>

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.

</div> <br>

<div style="color: purple">

### `asdf_bin_relpath`

<code>--golang-asdf-bin-relpath=<str></code><br> <code>PANTS_GOLANG_ASDF_BIN_RELPATH</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>bin</code></span>

<br>

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.

</div> <br>

## Deprecated options

None