How to build Go packages from private repositories
Written on October 4, 2019
Let’s say you have a Go package on a private repository which is tagged as v0.0.1
,
and want to build an application with it:
1. Create a go.mod file with the private repository
This will be the go.mod
file of your application:
2. Edit .gitconfig file
Put following lines to your ~/.gitconfig
file:
3. Set GOPRIVATE
Then set an environment variable, GOPRIVATE
:
You can put above lines in the .rc files, or even in your build scripts.
Then you’ll be able to build your application with packages on private repositories :-)
Please let me know if there is a better way!
Written on October 4, 2019