Commit 80613d98 authored by Ethan Reesor's avatar Ethan Reesor

Detail how to configure Go to skip checksum downloads

parent 00da5590
...@@ -29,24 +29,38 @@ NOTE: **Note:** ...@@ -29,24 +29,38 @@ NOTE: **Note:**
`go` does not support transmitting credentials over insecure connections. The `go` does not support transmitting credentials over insecure connections. The
steps below will only work if GitLab is configured for HTTPS. steps below will only work if GitLab is configured for HTTPS.
GitLab's Go proxy implementation supports HTTP Basic authentication for personal 1. Configure Go to include HTTP basic authentication credentials when fetching from the Go proxy for GitLab.
access tokens, in addition to the usual authentication mechanisms. To configure 2. Configure Go to *not* attempt to download checksums for private GitLab projects from the public checksum database.
Go to use HTTP Basic authentication, you must create a [personal access
token](../../profile/personal_access_tokens.md) with the `api` or `read_api` #### Enable Request Authentication
scope and add it to [`~/.netrc`](https://ec.haxx.se/usingcurl/usingcurl-netrc):
Create a [personal access token](../../profile/personal_access_tokens.md) with
the `api` or `read_api` scope and add it to
[`~/.netrc`](https://ec.haxx.se/usingcurl/usingcurl-netrc):
```netrc ```netrc
machine my-server machine <url> login <username> password <token>
login my-user
password my-token
``` ```
Replace `my-user` with your username and `my-token` with your personal access `<url>` should be the URL of the GitLab instance, for example `gitlab.com`.
token. The value of `my-server` should be `gitlab.com` or the URL of your GitLab `<username>` and `<token>` should be your username and the personal access
instance. You can optionally append a path to `my-server`, which will restrict token, respectively.
the scope that the credentials will be used for. For example, `machine
gitlab.com/my-group` will restrict the credentials to URLs starting with #### Disable Checksum Database
`gitlab.com/my-group`.
By default, Go will query `sum.golang.org` for module checksums. This will not
work modules that are not public. `GONOSUMDB` can be used to disable downloading
checksums for specific URLs. This can be permanently set with `go env -w
GONOSUMDB=<scope>`.
- `GONOSUMDB=gitlab.com/my/project` will disable checksum downloads for
`gitlab.com/my/project`
- `GONOSUMDB=gitlab.com/namespace` will disable checksum downloads for all
projects under `gitlab.com/namespace`
- `GONOSUMDB=gitlab.com` will disable checksum downloads for *all* modules on
GitLab.com
- `GOSUMDB=off` or `GONOSUMDB=*` will *completely* disable the checksum database
for all modules and packages.
## Add GitLab as a Go proxy ## Add GitLab as a Go proxy
...@@ -104,7 +118,7 @@ website. ...@@ -104,7 +118,7 @@ website.
The GitLab Go proxy will ignore modules and module versions that have an invalid The GitLab Go proxy will ignore modules and module versions that have an invalid
`module` directive in their `go.mod`. Go requires that a package imported as `module` directive in their `go.mod`. Go requires that a package imported as
`gitlab.com/my/project` can be accessed via that same URL, and that the first `gitlab.com/my/project` can be accessed with that same URL, and that the first
line of `go.mod` is `module gitlab.com/my/project`. If `go.mod` names a line of `go.mod` is `module gitlab.com/my/project`. If `go.mod` names a
different module, compilation will fail. Additionally, Go requires, for major different module, compilation will fail. Additionally, Go requires, for major
versions after 1, that the name of the module have an appropriate suffix, for versions after 1, that the name of the module have an appropriate suffix, for
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment