Overview of Creating Versions to Project

Also understanding of vendor versioning in go.

Janteshital
FAUN — Developer Community 🐾

--

In the previous blog, I have covered the fundamentals of the Go module, and dependency management in GoLang.
In this blog, I will try to cover adding versions to the project(tagging the module) and how to upgrade the vendor to a specific version.

What a Version means :

Version is an identifier for an irreversible snapshot of a module which is considered as a release or pre-release(beta versions).

It is written as the letter v(implies version) followed by a semantic version. Semantic versions are non-negative integers and are in the format of (major_version).(minor_version).(patch_version)

Following are some cases for each version:

patch_version MUST be incremented if only backward compatible bug fixes are introduced.
minor_version MUST be incremented if new, backward-compatible functionality is added. When incrementing the minor version the patch_version should be reset to 0.
major_version MUST be incremented if any backward-incompatible API changes are done, When incrementing the major version the minor_version.patch_version should be reset to 0.

Additional labels for pre-release and build metadata can be added as extensions to the (major_version).(minor_version).(patch_version)
format. For example: v.1.0.0+beta ,v2.1.12-pre

version-numbers

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.

Pseudo-version :

A version that has a revision identifier (such as a Git commit hash) and a timestamp from a version control system.

For example, v0.0.0–20191109021931-daa7c04131f5.
Pseudo-versions refer to revisions for which no semantic version tags are available.
They may be used to test commits before creating version tags, for example, on a development branch. Mainly used for testing for compatibility purposes.

There are two ways for creating versions in projects.
1.Create version while raising pull requests

git checkout -b <branch_name>git commit -m <commit_message>git push — set-upstream origin <branch_name>git tag -a <tag_name> -m <tag_message>git push origin tag <tag_name>

2. Create version after changes are merged to origin

git checkout origingit tag -a <tag_name> -m <tag_message>git push origin <tag_name>

Example:

$ git checkout master$ git tag -a v1.2.3 -m “stable version 1.2.3”$ git push origin v1.2.3

In the above example case “v1.2.3” is a tag name and the semantic version is “1.2.3”.

Upgrading Vendor Version in GoLang :

When you are using some dependencies in a project, those need to be updated with the latest changes as per needs.

Following are the steps for updating the vendor dependency changes in your local projects.

export GOPRIVATE=<git_url>git config — global url.git@<git_url>:.insteadOf https://<git_url>///now change the version of vendor package in go.mod filego mod tidygo mod vendor

go mod vendor omits go.mod and go.sum files for vendored dependencies, which can otherwise may create issues in the go command to identify the correct module root when invoked within the vendor tree.

go mod vendor add the go version from each dependency’s go.mod file in vendor/modules.txt.

Conclusion

Versioning is a way to identify the unique states of modules/software as it is developed and released.

When new features are introduced, bugs are fixed, or security holes are patched, the version number is increased to indicate the module/software includes those improvements

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Developers: Learn and grow by keeping up with what matters, JOIN FAUN.

--

--