How to use Go with a private GitLab repo

后端 未结 11 1676
时光说笑
时光说笑 2020-12-04 11:11

GitLab is a free, open-source way to host private .git repositories but it does not seem to work with Go. When you create a project it generates a URL of the fo

11条回答
  •  醉酒成梦
    2020-12-04 12:06

    GitLab version 11.8+ and Go version 1.13+ will work with BASIC auth by using your GitLab personal token. Go to Settings -> Access Tokens in your Gitlab, add a personal access token or use your existing one. In your ~/.netrc file, add following lines:

    machine  (e.g. gitlab.com)
    login 
    password 
    

    Then you should be able to do go get locally.

    If you need to build it in CI, then add following line in your .gitlab-ci.yml file:

    before_script:
        - echo -e "machine \nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
    

提交回复
热议问题