# How to make a private repository in Go
# Repository Preparation
Module in go.mod should be the same as the URL published. E.g.
# Configure git
Since Go uses git underhood, you have to ensure that the git has access to the private repository. module github.com/rug-ds-lab/2022-phd-mostafa-ecida-demo
You can use the git tag for publishing desired version. It uses the latest tag by default.
You should configure your git access to your private repository either by using ssh-key or username and access-token
# Ssh-key:
git config --global url."git@github.com:".insteadOf "https://github.com/"
More information:
https://medium.com/easyread/today-i-learned-fix-go-get-private-repository-return-error-terminal-prompts-disabled-8c5549d89045
Github user manual for connecting with SSH: https://docs.github.com/en/authentication/connecting-to-github-with-ssh
Check access by using git ls-remote
git ls-remote git@github.com:rug-ds-lab/2022-phd-mostafa-ecida-demo
# Access-token:
git config --global url."https://${user}:${personal_access_token}@github.com".insteadOf "https://github.com"
More info:
https://medium.com/cloud-native-the-gathering/go-modules-with-private-git-repositories-dfe795068db4
# Configure Go
And you should also set GOPRIVATE env
go env -w GOPRIVATE=github.com/rug-ds-lab
https://medium.com/swlh/go-modules-with-private-git-repository-3940b6835727
You can add module by:
go get github.com/rug-ds-lab/2022-phd-mostafa-ecida-demo/resources