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: 'go mod edit -replace' fails if the package's version in go.mod is not in semver format #34382

Open
rafaelvanoni opened this issue Sep 18, 2019 · 3 comments

Comments

@rafaelvanoni
Copy link

@rafaelvanoni rafaelvanoni commented Sep 18, 2019

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

$ go version
go version go1.12 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/rafael/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/rafael/Work/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.12"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.12/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/rafael/Work/go/src/github.com/rafaelvanoni/kube-controllers-private/go.mod"
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-build260011560=/tmp/go-build -gno-record-gcc-switches"

What did you do?

A simplified example suggested by @heschik is to run the following command twice:

go mod edit -replace golang.org/x/tools@latest=github.com/golang/tools@latest 

What did you expect to see?

What did you see instead?

A "version must be of the form v1.2.3" error.

@rafaelvanoni
Copy link
Author

@rafaelvanoni rafaelvanoni commented Sep 18, 2019

Workaround as suggested by @thepudds and @heschik is to run go list -m all or go mod tidy

@rafaelvanoni
Copy link
Author

@rafaelvanoni rafaelvanoni commented Sep 19, 2019

I'd be happy to contribute a patch if someone has a few minutes to point me in the right direction

@jayconrod jayconrod changed the title go mod edit replace fails if the package's version in go.mod is not in semvar format cmd/go: 'go mod edit -replace' fails if the package's version in go.mod is not in semver format Mar 16, 2020
@hitzhangjie
Copy link
Contributor

@hitzhangjie hitzhangjie commented May 3, 2020

go mod edit -replace old@${v}=new@{vv}, here, could we specify a branch for placeholder ${vv}.

Now it is not supported, a little inconvenient. But @commithash can workaround.

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
3 participants
You can’t perform that action at this time.