Skip to content

FAQ

How do I resolve private modules using go mod?

Set $GOPRIVATE environment variable

# Add to `~/.bashrc` file
export GOPRIVATE="gitlab.group.team.blue"

# OR

# Persist in GO config file
go env -w GOPRIVATE=gitlab.group.team.blue

Re-write Git URL

Run the following command in the terminal:

git config --global url."git@gitlab.group.team.blue:".insteadOf "https://gitlab.group.team.blue"

Create GitLab Personal Access Token

Go to: GitLab and create the token with read_api and read_repository permissions for use in the next step. Save the access token somewhere safe like in your ~/.bashrc file.

Create ~/.netrc file

Add the following after editing the relevant data:

machine gitlab.group.team.blue
login <GITLAB_USERNAME> # Get this from your GitLab profile page and the username is what follows after `@`.
password <GITLAB_PERSONAL_ACCESS_TOKEN>

You're all set to run go mod tidy!!!!