Skip to content

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

Closed
@shoenig

Description

@shoenig

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.

Activity

AlexRouSg

AlexRouSg commented on Sep 1, 2018

@AlexRouSg
Contributor

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

myitcv commented on Sep 1, 2018

@myitcv
Member

Closing per @AlexRouSg's response

locked and limited conversation to collaborators on Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @shoenig@myitcv@AlexRouSg@gopherbot

        Issue actions

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