Semantic Versioning on Private Library Package for Golang 1.13


What we need?

  • Golang version 1.13 or above

    • GOPRIVATE introduced to go module since 1.13
    • multi section of GOPROXY introduced to go module since 1.13
  • Running Gitlab

    • Certainly, We need it host our private code. I assumed your gitlab running happily at

Configure go.mod file for Library Package

  • Init a package named group/project

    go mod init
  • 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 GOPRIVATE and GOPROXY works as well as we expect.

    Be careful :

    • means : all Packages from was private package, go build will skip checksum cuz we trust our teammate. lol.
    • You may have your own setting of GOPROXY, always make sure direct section was placed EXACTLY at the end of this line. For now, our configuration means : If go build can't find package via Then it will try to find it via
  • Access your git repo

    • Use SSH instead of HTTP

      git config --global url."".instead of ""
    • Setup SSH public key on gitlab, You can easily make it via Google.
  • Pull the Trigger

    • Import library package and use it

      go get -u -v
      go build -v .

Migrate to Docker

  • Use key pair for Docker build

    ssh-keygen -f /path/to/build-key

    Change your docker file

    COPY/path/to/build-key` ~/.ssh/id_rsa

    Setup SSH public key /path/to/ on gitlab.

阅读 1.1k

2.4k 声望
66 粉丝
0 条评论

2.4k 声望
66 粉丝