Skip to content

Instantly share code, notes, and snippets.

@steelx
Last active November 14, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steelx/1e75a8285b3d61e7f9c283f366bd5607 to your computer and use it in GitHub Desktop.
Save steelx/1e75a8285b3d61e7f9c283f366bd5607 to your computer and use it in GitHub Desktop.
Add version to GO package

Tag your git repository with a version number (ideally based on the semantic versioning specification e.g. v0.0.0).

git tag -a v0.0.0 -m "First tag." Push the version number to the remote repository.

git push --tags Generate an up-to-date version_PLATFORM.go file (normally done by your CI server)

go generate The version_PLATFORM.go file gets automatically updated with data from the tag. Build as normal

go build

optional

overwite commit to an existing TAG git push --tags -f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment