The semantics of Go module versions
Vladimir Vivien
Software Engineer | Build stuff in Go | Kubernetes Contributor | LinkedIn Instructor
When you are developing Go modules (executables or libraries), at some point you will want to release them and make them available to others (whether internally or publicly). As your module improves over time, with bug fixes and new features, you will want to release new version of the software to share your work with your community of users.
Fortunately, instead of an arbitrary version label, Go has adopted a standard way of labeling module versions known as Semantic Versioning (or SemVer). Semantic versioning combines three different version numbers to communicate to users the type of changes their potential impact to the user community.
SemVer labels have a simple format where they start with the letter "v" followed by 3 dot-separated numbers as shown below:
vMAJOR.MINOR.PATCH
The reason why it is called semantic versioning is because each number in the version label has a specific meaning.
Here are some examples of semantic version labels:
v0.1.0
v0.1.2
v0.6.0
v1.0.0
Unstable version semantics
Using semantic versioning, we can express that a given version is considered unstable. An unstable version is one that?makes no compatibility guarantees with previous versions.
Major version Zero?
When the MAJOR version number is zero (v0) it indicates that the module is still under initial development and may experience breaking changes. This means that v0.2.0 any other previous version v0 versions are not guaranteed to be API compatible. That being said, most project authors tend to honor that guarantee anyway even when using v0.
Examples of versions zero releases:
v0.1.0
v0.34.1
领英推荐
Pre-released versions
The semantic label string can include a trailing text (appended after the PATCH). It is there for additional version context information. Specifically, it is used to provide information about a pre-released versions which may not be backward compatible with previous versions.
Example pre-released versions:
v0.5.0-beta
v1.0.0-rc1
Why it matters
Semantic versioning offers several crucial benefits for both module developers and users:
Summary of versioning your modules
Here's a summarized list of how you should evolve your own module over time:
Beyond v1 - releasing the next major version
Increasing the MOJOR version from v1 -> v2 has major implications. You are indicating to your user base that your API has no guaranteed of backward compatibility. Beside the maintenance overhead (if you want to continue to support the v1 versions), user using v1.x.x family will be required change their import paths to pick up the new v2 versions.
Learn more
You can learn more about Go modules and how to use effectively use semantic versioning for your modules in LinkedIn course Programming with Go Modules.