go version)?go version go1.11.4 linux/amd64
yes
go env)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tki/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tki/go"
GOPROXY=""
GORACE=""
GOROOT="/snap/go/3095"
GOTMPDIR=""
GOTOOLDIR="/snap/go/3095/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/tki/src/gitlab.com/tkiraly/auxtest/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-build672569542=/tmp/go-build -gno-record-gcc-switches"
go get gitlab.com/tkiraly/auxtest in a directory where there is another project with go.mod
i expected to download the module as a dependency
go: finding gitlab.com/tkiraly/auxtest latest
go: downloading gitlab.com/tkiraly/auxtest v0.0.0-20190106140156-e164048c9957
-> unzip /home/tki/go/pkg/mod/cache/download/gitlab.com/tkiraly/auxtest/@v/v0.0.0-20190106140156-e164048c9957.zip: malformed file path "aux.go": disallowed path element "aux.go"
go get: no install location for directory outside GOPATH
For more details see: 'go help gopath'
after renaming the file, the error disappear. aux is a reserved file name??
I can reproduce on tip. Looks like this is on purpose:
// badWindowsNames are the reserved file path elements on Windows.
// See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file
var badWindowsNames = []string{
"CON",
"PRN",
"AUX",
[...]
I'm not sure if we could make the error better without leaking too much internal detail. /cc @bcmills
Clearly we should improve the error message. It's right there in cmd/go/internal/module/module.go:
for _, bad := range badWindowsNames {
if strings.EqualFold(bad, short) {
return fmt.Errorf("disallowed path element %q", elem)
}
}
Any suggestions for what we should say?
Since "malformed file path" is already part of the error message, I think "reserved file path "aux"" might be clearer.
So - malformed file path "aux.go": reserved path element "aux"
Thanks. I sort of feel that we should mention Windows somehow.
How about:
malformed file path "aux.go": file name is reserved on some systems
I'd personally say "some systems" instead of "Windows" so we can later add more reserved names on other systems without introducing more error formats.
The variable name says badwindowsnames so we can say windows not just some systems
However this still misses the key part, that 'aux' word is reserved not aux.go as a whole
How about this?
malformed file path "aux.go": file name part "aux" is reserved on windows
I would prefer that we mention Windows explicitly. Some context will probably help folks feel less confused about why an otherwise-reasonable-looking name is disallowed.
We can wordsmith the exact text in the code review.
Change https://golang.org/cl/156658 mentions this issue: cmd/go: improve error message for names forbidden by Windows
Most helpful comment
Thanks. I sort of feel that we should mention Windows somehow.