-
-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow inclusion of extra tools in sandbox for go backend (#21309)
This adds the git binary to the go backend so that `go mod download` can retrieve modules in private repositories. Addresses issues #21292 specifically for private modules and #12625 This PR also includes a short document on how to use pants with a go module from a private git repo.
- Loading branch information
Showing
5 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Private Modules", | ||
"position": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: Private Modules | ||
sidebar_position: 1 | ||
--- | ||
|
||
Use Golang modules from private repositories | ||
|
||
--- | ||
# Using Private Modules in Golang | ||
|
||
Pants can build go binaries that use modules from private git repositories. | ||
To do this specify the private repo(s) in `GOPRIVATE` and provide credentials for the git repo in your `$HOME/.netrc`. | ||
|
||
Define the `GOPRIVATE` variable in the `subprocess_env_vars` section of your `pants.toml`. The example below shows the `.netrc` file so that git can authentcate. A simple `go.mod` shows the inclusion of the private module, nothing special here. | ||
|
||
|
||
```toml tab={"label":"pants.toml"} | ||
[GLOBAL] | ||
backend_packages.add = [ | ||
"pants.backend.experimental.go", | ||
] | ||
|
||
|
||
[golang] | ||
subprocess_env_vars = [ | ||
'GOPRIVATE=github.com/your-user/your-module/*', | ||
'HOME', | ||
] | ||
extra_tools = [ | ||
'git', | ||
] | ||
``` | ||
|
||
```go tab={"label":"go.mod"} | ||
module consumer | ||
|
||
go 1.22 | ||
|
||
require github.com/your-user/your-repo/your-module v0.0.1 | ||
``` | ||
|
||
``` tab={"label":".netrc"} | ||
machine github.com | ||
login your-user | ||
password your-token | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters