SoFunction
Updated on 2025-03-05

Analysis of the problem of using Pseudo-versions in golang

sequence

This article mainly studies golang's Pseudo-versions

Pseudo-versions

definition

Pseudo-versions, which probably means pseudo-version in Chinese, means that there is no semantic version tag (semantic version tags) will use pseudo version

Format

similarv0.0.0-yyyymmddhhmmss-abcdefabcdef, the intermediate time is UTC time (East Eight District is UTC+8), the last 12 bits are the first 12 bits of the hash of git commit

forms

vX.0.0-yyyymmddhhmmss-abcdefabcdef

If there is no semantic version of major tag before, the first part of its Pseudo version is vX.0.0

-pre.-abcdefabcdef

In -pre(v3.9.0-preThe first part of the commit submitted after the ) version is -pre.0(v3.9.0-pre.0)

.(Z+1)--abcdefabcdef

exist(v3.9.0The first part of the commit submitted after the ) version is.(Z+1)-0(v3.9.1-0)

+incompatible

For some dependencies that do not have them, it will appear+incompatible,for example

/google/martian v2.1.0+incompatible/ h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=

question

The version based on the branch commit will cause go mod invalid version after the change commit is deleted.

For example, when combining feature branches into the maingit merge --squashAnd the method of deleting feature branches at the same time will cause the commit that depends on the previous dependency feature branches to be lost, and eventually the project that depends on this commit cannot be built.

When the tag is deleted, go mod invalid version will also appear.

Other languages ​​such as java's maven are managed by the warehouse. Unless in special circumstances, the warehouse will not delete the version, and there will generally be no error operations. Pay special attention to this point of go, and be careful when deleting tags.

summary

Go's Pseudo-versions is a bit similar to the concept of maven's snapshot, and they are all based on timestamps. However, Go's repository is based on git repository, so it brings the hash information of commit. But pay special attention to the problem of go mod invalid version.

  • Pseudo-versions
  • Where pseudo version with non-existent tag
  • Why go module pseudo version have a specific version?
  • Go Big With Pseudo-Versions and GoCenter

The above is the detailed analysis of the problem of using Pseudo-versions in golang. For more information about using Pseudo-versions in golang, please pay attention to my other related articles!