Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 4
    There's something that always rubbed me the wrong way about configuring git globally just so that Go dependencies can be downloaded. But doesn't this have that same problem? You're configuring a tool used by your entire system (in this case, if I understand .netrc properly, the way your machine performs every HTTP request) just so that Go dependencies can be downloaded. In fact, this way seems risky, since wouldn't it include that token with every request you send to that host? Commented Feb 2, 2021 at 16:42
  • 1
    Thank you, For gitlab the following worked for me echo "machine gitlab.example.com login gitlab-ci-token password ${CI_JOB_TOKEN}" > ~/.netrc && chmod 600 ~/.netrc Commented Oct 26, 2021 at 19:33
  • 1
    Thanks! Little note for windows: %HOME%\_netrc file there. Commented Dec 1, 2022 at 7:01
  • Using netrc is a bad advice as your password is stored in clear. Use instead the git credentials helper for you password store. See git help credentials. Commented Jun 28, 2024 at 14:00
  • There is a known issue when working with Gitlab. When trying to pull from a private repository, which is located inside a private subgroup, your request will fail, as "go get" makes an unauthenticated request to discover the repository path. This was the only solution that worked for me in this scenario Link to the related Gitlab documentation docs.gitlab.com/user/project/use_project_as_go_package/… Commented Oct 2, 2025 at 8:38