Thursday, 5 December 2019

Golang and private gitlab repos and 410 Gone

I've been following a microservices with golang tutorial recently, and needed to refer to one project from another.

After getting numerous errors with `go get` and much searching for answers, I stumbled across this solution.

In Gitlab add a personal access token.

In your ~/.netrc file add:

machine gitlab.com
  login {{personal_access_token_name}}
  password {{personal_access_token}}


Replacing the prompts with the actual values.

In your .bashrc add

export GOPRIVATE="gitlab.com/{{path_to_project}}"


This is working for me, a similar approach may well work with bitbucket or codebasehq.

1 comment:

  1. Nice!

    You can avoid tinkering with your shell startup scripts to persist your setting by using the go tooling, which maintains user-defined changes to the "sensible defaults" Go uses.

    $ go env -w GOPRIVATE="gitlab.com/{{path_to_project}}"

    (This actually updates a file in $HOME/.config/go/env - which you could also edit by hand)

    ReplyDelete