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: On Windows, sometimes (but not always) uses backslashes in printed import paths. #15040

Closed
dmitshur opened this issue Mar 31, 2016 · 1 comment
Milestone

Comments

@dmitshur
Copy link
Contributor

$ go version
go version go1.6 windows/386

$ go env
set GOARCH=386
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Documents and Settings\Dmitri\Dmitri\GoLand
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_386
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

(For testing purposes only, I don't actually use Windows XP.)

What did you do?

On Windows (or any other OS where os.PathSeparator is not /), I started with a clean GOPATH, and ran the following command two times in a row:

go get -d -u -v golang.org/x/net/context

What did you expect to see?

$ go get -d -u -v golang.org/x/net/context
...
golang.org/x/net (download)

$ go get -d -u -v golang.org/x/net/context
...
golang.org/x/net (download)

What did you see instead?

$ go get -d -u -v golang.org/x/net/context
...
golang.org/x/net (download)

$ go get -d -u -v golang.org/x/net/context
...
golang.org\x\net (download)

Notice the backslashes instead of forward slashes in the second line of output.

(I've snipped irrelevant parts of output with ....)

Cause

It happens in src/cmd/go/get.go#L412. That prints value of rootPath, which comes from one of two paths, depending on src/cmd/go/get.go#L347. The problem is in the top-most path, when rootPath value comes from vcsForDir which contains a bug (it doesn't do what its documentation says it does).

This is a bug that was reported and fixed in golang.org/x/tools/go/vcs.FromDir, an exported copy of that function. It was fixed in golang/tools@5804fef. However, it hasn't yet been backported to cmd/go.

I have a CL that I'll submit now that resolves this issue.

@gopherbot
Copy link

CL https://golang.org/cl/21345 mentions this issue.

@bradfitz bradfitz added this to the Go1.7 milestone Apr 9, 2016
@golang golang locked and limited conversation to collaborators Apr 12, 2017
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

3 participants