Semantic Versioning on Private Library Package for Golang 1.13
What we need?
Golang version 1.13 or above
GOPRIVATEintroduced to go module since 1.13- multi section of
GOPROXYintroduced to go module since 1.13
Running Gitlab
- Certainly, We need it host our private code. I assumed your gitlab running happily at http://foo.bar.com
Configure go.mod file for Library Package
Init a package named
group/projectgo mod init foo.bar.com/group/project- Write some bugs with few lines of functional code, then commit and push.
Release your package with Semantic Version
git tag -a v1.0.0 -m "release v1.0.0 for semantic version testing"git push --tags- Checkout your hard work on Gitlab.
Use Private Library Package For Versioning
Make sure your
GOPRIVATEandGOPROXYworks as well as we expect.GOPRIVATE=foo.bar.comGOPROXY=https://goproxy.io,directBe careful :
GOPRIVATE=foo.bar.commeans : all Packages fromfoo.bar.comwas private package, go build will skip checksum cuz we trust our teammate. lol.- You may have your own setting of
GOPROXY, always make suredirectsection was placed EXACTLY at the end of this line. For now, our configuration means : If go build can't find packagefoo.bar.com/group/projectviahttps://goproxy.io/group/projectThen it will try to find it viahttp://foo.bar.com/group/project
Access your git repo
Use
SSHinstead ofHTTPgit config --global url."[email protected]:".instead of "http://foo.bar.com/"- Setup
SSHpublic key on gitlab, You can easily make it via Google.
Pull the Trigger
Import library package and use it
go get -u -v foo.bar.com/group/[email protected]go build .- EOF
相关推荐
lwnylslwnyls 2020-11-06
yanzhelee 2020-10-13
guojin0 2020-10-08
佛系程序员J 2020-10-08
bluewelkin 2020-09-16
wwzaqw 2020-09-04
zhongdaowendao 2020-09-02
favouriter 2020-08-18
奎因amp华洛 2020-08-15
一青年 2020-08-13
千锋 2020-08-10
nangongyanya 2020-08-09
dongxurr 2020-08-08
明天你好 2020-08-03
kyelu 2020-08-03
Ashes 2020-08-03