Go Modules

VSETH has some published Go modules taking care of functionalities used in many Go applications. All these packages can be found here: https://go.getsip.ethz.ch and have an import path of the form https://go.getsip.ethz.ch/<module-name>.

See here for a blog article explaining more about Go modules.

Creating your own published Go module

Create a Go project as you would usually in a public repository (vseth/0403-isg/libraries is probably a good option). Make sure it has an up-to-date go.mod file with a module path of the from  go.getsip.ethz.ch/<module-name>.

Since this code is published publicly, it should have a licence. We recommend TBD.

Creating a go.mod file

Running go mod init will create a go.mod file with only the module and go directives. Note that the module name is not the gitlab path but go.getsip.ethz.ch/<module-name>.
Next, run go mod tidy to add all dependencies to the go.mod file and build a go.sum file containing checksums for each library at the specified version.

Adding a License

See Licenses to decide which license you should use.

Publishing a release

Your first version should probably be v0. This does not make any stability guarantees. Once the API is stable, you can start with normal versioning.

Make sure you follow semantic versioning: A semantic version has the form vMAJOR.MINOR.PATCH.

  • Increment the MAJOR version when you make a backward-incompatible change to the public API of your module. This should only be done when absolutely necessary.
  • Increment the MINOR version when you make a backward-compatible change to the API, like changing dependencies or adding a new function, method, struct field, or type.
  • Increment the PATCH version after making minor changes that don’t affect your module’s public API or dependencies, like fixing a bug.

Simply tag the release with the correct version and push it.

Publishing the module on go.getsip.ethz.ch

Next, you can add this module to our go.getsip.ethz.ch. For this, simply add an entry for your package to the vanity.yml file in the Go Vanity Urls repository.

This entry should have the same form as this example for a package located at https://gitlab.ethz.ch/vseth/0403-isg/libraries/>



vanity.yml entry
/<name>:
    repo: https://gitlab.ethz.ch/vseth/0403-isg/libraries/<name>
    display: "https://gitlab.ethz.ch/vseth/0403-isg/libraries/<name> https://gitlab.ethz.ch/vseth/0403-isg/libraries/<name>/tree/<default-branch>{/dir} https://gitlab.ethz.ch/vseth/0403-isg/libraries/<name>/blob/<default-branch>{/dir}/{/file}-{line}"
	vcs: git



Things to look out for

  • Most of our modules are probably highly VSETH specific or have "VSETH defaults". Consider adding a statement about this to the ReadMe so a random dev who stumbles over our package is aware of this.
  • I sometimes had issues with go get trying to pull our modules if the version tagged was below v0.1.0.