Search code examples
goversiongo-modules

Why go module pseudo version have a specific version?


I have a go.mod looks like

require(
   ...
   github.com/google/wire v0.3.1-0.20190716160000-66f78fc84606
   ...
)

Based on my understanding, if a package looks like that (yyyymmddMMSS-commit_id), which version should be v0.0.0 but not v0.3.1 as this example.

Could someone guide me how should I explain this? Does go mod ignore the v0.3.1- prefix?


Solution

  • It's the result of go get'ing a specific commit that exists in the tree after a semantic version tag:

    go get github.com/google/wire@66f78fc84606

    Pseudo versions are used not only when there is no version tag. As the official documentation about pseudo versions shows:

    Pseudo-versions may 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.

    ...

    vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdefabcdef is used when the base version is a release version like vX.Y.Z.

    In this case, the repository does have semantic version tags. The base version here is v0.3.0, and by getting a specific commit (66f78fc84606) that exists after v0.3.0 and before the next one v0.4.0, you end up with:

    github.com/google/wire v0.3.1-0.20190716160000-66f78fc84606