How to access private repos in Go

When downloading packages, Go checks the public Go Checksum Database to verify the package checksum. Private Git packages, such as those on a private GitLab instance, aren’t in that database, so downloading them will fail. This can be fixed by setting GOPRIVATE=private.example.com. This instructs Go not to check the Checksum Database for packages in the private.example.com domain. For GitLab, first set up access to repositories: Create a GitLab Access Token with the read_api scope. Update your ${HOME}/.netrc file, and add: machine private.example.com login your.email@example.com password gitlab_access_token More information can be found in the GitLab documentation. ...

August 26, 2024 · 1 min

Set up a different Go version for a project

Let’s say you have Go 1.20.1 installed locally, but the project you are working on requires Go 1.22.3. First, install the additional version of the Go SDK. VS Code Set GOROOT to point to the Go version you need. Add the following to the workspace settings: "go.goroot": "${env:HOME}/sdk/go1.22.3" GoLand Go to Settings → Go → GOROOT and add or select the version you need there.

August 26, 2024 · 1 min