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: module names are mangled when GOPROXY is set #27435

Closed
shoenig opened this issue Sep 1, 2018 · 2 comments
Closed

cmd/go: module names are mangled when GOPROXY is set #27435

shoenig opened this issue Sep 1, 2018 · 2 comments

Comments

@shoenig
Copy link
Contributor

shoenig commented Sep 1, 2018

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

[k9 test] $ go version
go version go1.11 linux/amd64

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

[k9 test] $ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hoenig/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/hoenig/Documents/go"
GOPROXY="file://tmp/foo"
GORACE=""
GOROOT="/opt/google/go"
GOTMPDIR=""
GOTOOLDIR="/opt/google/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/hoenig/Documents/go/src/github.com/shoenig/test/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-build114829655=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When serving modules through a proxy (toy code below using 1 module served via file://), the go command seems to be making requests with a mangled URL (e.g. capital letters get weird).

If possible, provide a recipe for reproducing the error.

First, showing nothing bad happens if we use no proxy:

[k9 test] $ export GO111MODULE=on
[k9 test] $ go mod init
go: creating new go.mod: module github.com/shoenig/test
[k9 test] $ go mod edit -require github.com/BurntSushi/toml@v0.0.0-20170626110600-a368813c5e64
[k9 test] $ go build
go: finding github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64

Now, we set GOPROXY to a custom value, it does not matter what the value is.

[k9 test] $ export GOPROXY=file:///dev/null
[k9 test] $ go build
go: finding github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64
go: github.com/BurntSushi/toml@v0.0.0-20170626110600-a368813c5e64: open /dev/null/github.com/!burnt!sushi/toml/@v/v0.0.0-20170626110600-a368813c5e64.info: not a directory
go: error loading module requirements

Notice that go is making a request for github.com/!burnt!sushi/toml instead of github.com/BurntSushi/toml.

@AlexRouSg
Copy link
Contributor

AlexRouSg commented Sep 1, 2018

This is documented behavior, see:

https://tip.golang.org/cmd/go/#hdr-Module_proxy_protocol

To avoid problems when serving from case-sensitive file systems, the <module> and <version> elements are case-encoded, replacing every uppercase letter with an exclamation mark followed by the corresponding lower-case letter: github.com/Azure encodes as github.com/!azure.

@myitcv
Copy link
Member

myitcv commented Sep 1, 2018

Closing per @AlexRouSg's response

@myitcv myitcv closed this as completed Sep 1, 2018
@myitcv myitcv added the modules label Sep 1, 2018
@golang golang locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants