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 get' fails to track a branch which contains a `/` #38861

Open
grellyd opened this issue May 4, 2020 · 0 comments
Open

cmd/go: 'go get' fails to track a branch which contains a `/` #38861

grellyd opened this issue May 4, 2020 · 0 comments

Comments

@grellyd
Copy link

@grellyd grellyd commented May 4, 2020

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

$ go version

go version go1.14.2 darwin/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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/grellyd/Library/Caches/go-build"
GOENV="/Users/grellyd/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY="go.company.io"
GONOSUMDB="go.company.io"
GOOS="darwin"
GOPATH="/Users/grellyd/wrk/go"
GOPRIVATE="go.company.io"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.2_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/grellyd/wrk/go/src/go.company.io/repo/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/34/mxhn7dp54z9fp1phcl1t0mr80000gn/T/go-build088434320=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I was attempting to test changes in a branch of a vendored dependency on a private repository. Having never done this before using go modules, I found the docs (https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) which indicated I should go get the associated repo and have the default version overridden by adding an @version suffix to the package argument, as in 'go get golang.org/x/text@v0.3.0'.

I assumed from there that I should add the branch as the checkout point. This resulted in the error below, indicating the version string was disallowed. Our company namespaces our github branches before doing the proper branch name. For us, slashes in the branch name are a common workflow. We occasionally also use multiple sub-namespaces for organisation.

Upon further research, I found a docs issue (#30851), and an associated issue (#36902). After commenting on the final issue, I opened this one.

A workaround at this time is to git log the sha of the HEAD of the namespaced branch and then go get using that sha. EG: go get github.com/org/repo@sha

An ideal configuration would download new commits upon a subsequent go get, which the sha checkout would not.

What did you expect to see?

go get github.com/org/repo@namespace/branch downloading and checking out that go module at that branch sha.

What did you see instead?

go get github.com/org/repo@namespace/branch: github.com/org/repo@namespace/branch: invalid version: version "branch" invalid: disallowed version string

@jayconrod jayconrod added this to the Backlog milestone May 5, 2020
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
2 participants
You can’t perform that action at this time.