Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: accept tags of the form X.Y.Z (without leading 'v') as semantic versions #32945

Open
tamalsaha opened this issue Jul 4, 2019 · 10 comments
Open

Comments

@tamalsaha
Copy link

@tamalsaha tamalsaha commented Jul 4, 2019

What version of Go are you using (go version)?

$ go1.13beta1 version
go version go1.13beta1 linux/amd64
$ go version
go version go1.12.6 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tamal/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tamal/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build803673677=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ go1.13beta1 get github.com/kubedb/apimachinery@v0.11.0
go: finding github.com/kubedb/apimachinery v0.11.0
go: finding github.com/kubedb/apimachinery v0.11.0
go: finding github.com v0.11.0
go: finding github.com/kubedb v0.11.0
go get github.com/kubedb/apimachinery@v0.11.0: unknown revision v0.11.0

$ go1.13beta1 get github.com/kubedb/apimachinery@0.11.0
go: finding github.com/kubedb/apimachinery 0.11.0

We use the git tag also as the Docker image tag. I like kubedb/operator:1.0.0 (without v) over kubedb/operator:v1.0.0. So, we went with that. Tools like glide, dep will automatically handle the presence or absence of v. But go mod does not do that.

What did you expect to see?

My question is can go mod automatically search for both of these prefixes?

What did you see instead?

@dmitshur dmitshur added this to the Go1.14 milestone Jul 4, 2019
@dmitshur dmitshur changed the title Automatically handle vX.Y.Z and X.Y.Z cmd/go: automatically handle vX.Y.Z and X.Y.Z Jul 4, 2019
@bcmills bcmills changed the title cmd/go: automatically handle vX.Y.Z and X.Y.Z cmd/go: accept tags of the form X.Y.Z (without leading 'v') as semantic versions Jul 18, 2019
@bcmills
Copy link
Member

@bcmills bcmills commented Jul 18, 2019

See previously #30146.

@bcmills
Copy link
Member

@bcmills bcmills commented Jul 18, 2019

CC @jayconrod

To reiterate from that discussion: the difference is mainly aesthetic and relatively arbitrary. Absent a compelling need otherwise, Go usually resolves aesthetic differences by picking one to use consistently (think of gofmt), not supporting both.

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Jul 18, 2019

+1 to not supporting this. It's unfortunate that different systems have different standards for this, but supporting both formats would lead to ambiguity and confusion. For example, both vX.Y.Z and X.Y.Z might exist and point to different commits.

go release should probably warn against creating such a version accidentally in the future.

@bcmills
Copy link
Member

@bcmills bcmills commented Jul 18, 2019

supporting both formats would lead to ambiguity and confusion

Note that there is a similar problem for build metadata, which we resolve (in Go 1.13) by resolving to a unique pseudo-version derived from the tagged version.

@mattharr-is
Copy link

@mattharr-is mattharr-is commented Oct 16, 2019

i think the ironic part about all of this is this bit in the semver.org FAQ
https://semver.org/#is-v123-a-semantic-version
In my case, we have an existing build system that handles repo versioning and tagging for us, using standard semver format (no v prefix). When one reads the go module docs about how it all works with a "standard semver format", and then seeing that it's not actually standard semver format, is a bit confusing. It also requires retooling some build processes that actually do follow the standard.

@alexellis
Copy link

@alexellis alexellis commented Feb 5, 2020

+1 cc @LucasRoesler @Waterdrips @stefanprodan - we were all hit by this today, we use semver but "the valid way" i.e. without a "v" prefix and dep was fine for us - we could have a proper tag in our dependency file, but now we're stuck with lots of v0.0.0 SHA in all our code. Was hoping that moving to go modules was going to be a pleasant, pain-free upgrade.

We don't want to change the tags if we can avoid it because semver itself recommends against no prefix and also, we rely on the numbering for Docker images.

wadells added a commit to wadells/robotest that referenced this issue May 13, 2020
As discussed at:

  golang/go#32945
  https://semver.org/#is-v123-a-semantic-version

Go and semver disagree about handling of a leading 'v' on version
strings.  This patch allows robotest to play nicely with both.
wadells added a commit to wadells/robotest that referenced this issue May 13, 2020
As discussed at:

  golang/go#32945
  https://semver.org/#is-v123-a-semantic-version

Go and semver disagree about handling of a leading 'v' on version
strings.  This patch allows robotest to play nicely with both.
wadells added a commit to wadells/robotest that referenced this issue May 13, 2020
As discussed at:

  golang/go#32945
  https://semver.org/#is-v123-a-semantic-version

Go and semver disagree about handling of a leading 'v' on version
strings.  This patch allows robotest to play nicely with both.

Contributes to gravitational#200.
wadells added a commit to gravitational/robotest that referenced this issue May 14, 2020
As discussed at:

  golang/go#32945
  https://semver.org/#is-v123-a-semantic-version

Go and semver disagree about handling of a leading 'v' on version
strings.  This patch allows robotest to play nicely with both.

Contributes to #200.
@wadells wadells mentioned this issue Jun 4, 2020
8 of 8 tasks complete
@gudvinr
Copy link

@gudvinr gudvinr commented Jul 9, 2020

We consistently use unprefixed tags X.Y.Z versions across all of the internal projects. Some of them are shared between projects and not every project is written in Go. This is really annoying requirement because it is not language-related but still ruining existing workflow.

Arguments like "you may have both prefixed and unprefixed tags in repo" is quite silly because if you do have such tags in your repo you probably have a bigger problem with your VCS already.

You may as well have very old commit tagged by higher version number and this also doesn't look right. You may have tags with same version and different metadata which is not used in version comparison too.

@gudvinr
Copy link

@gudvinr gudvinr commented Jul 9, 2020

the difference is mainly aesthetic and relatively arbitrary.

@bcmills This is not aesthetic for projects that existed outside of Google (and companies that use prefixed tags) before introduction of go modules. It is messing up with build process.

Reference to gofmt also seems wrong here. gofmt is tool for Go language only and can't interfere with anything outside Go ecosystem, but requirement on git tags leads to unwanted changes.

@taiidani
Copy link

@taiidani taiidani commented Jul 22, 2020

Agreeing with the above. My company is highly polyglot among multiple languages but our release and tagging automation is reused between them. We implemented this logic using the "correct" semver way without the "v" prefix.

It will be an extremely bitter pill to swallow if we have to update our automation and [ideally] re-tag all of our repositories to add the "v" prefix because of one languages' requirement.

@MCBrandenburg
Copy link
Contributor

@MCBrandenburg MCBrandenburg commented Aug 12, 2020

I'm in the a similar boat to @taiidani, trying to get a company to prefix with their already automated process with a v to satisfy the case for go FusionAuth/go-client#32

gotgenes added a commit to gotgenes/getignore that referenced this issue Aug 28, 2020
This is to support using go mod, and is necessary until
golang/go#32945 is resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.