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 github.com\alexbrainman\gowingui" should succeed on Mac #24233

Open
alexbrainman opened this Issue Mar 4, 2018 · 4 comments

Comments

Projects
None yet
8 participants
@alexbrainman
Member

alexbrainman commented Mar 4, 2018

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

go version go1.10 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Alex\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=c:\users\alex\dev
set GORACE=
set GOROOT=c:\users\alex\dev\go
set GOTMPDIR=
set GOTOOLDIR=c:\users\alex\dev\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\Alex\AppData\Local\Temp\go-build838310042=/tmp/go-build -gno-record-gcc-switches

What did you do?

I run

go get github.com\alexbrainman\gowingui

command.

What did you expect to see?

I expected command to fail, because I used \ instead of / in package import path.

What did you see instead?

I see no error message, and I also see gowingui.exe in my %GOPATH%\bin directory.

Comments

I discovered this while investigating #24232

And if I run

go install -ldflags "-H windowsgui" github.com\alexbrainman\gowingui

the %GOPATH%\bin\gowingui.exe file does not have IMAGE_SUBSYSTEM_WINDOWS_GUI flag set properly.

So if this issue is rejected as working as intended, than we should fix cmd/go flag processing to avoid cases like #24232

Alex

@ysmolsky

This comment has been minimized.

Member

ysmolsky commented Mar 4, 2018

Windows:

C:\Users\thorn>go get -v github.com\alexbrainman\gowingui
github.com/alexbrainman/gowingui (download)

Mac:

thorn@t2 ...go/src/playground % go get -v 'gitfhub.com\alexbrainman\gowingui'
https fetch failed: parse https://gitfhub.com\alexbrainman\gowingui: invalid character "\\" in host name

This happens in ImportPathsNoDotExpansion function
https://github.com/golang/go/blob/master/src/cmd/go/internal/load/search.go#L360-L362

which is called by downloadPaths: https://github.com/golang/go/blob/master/src/cmd/go/internal/get/get.go#L172

On windows go get silently fixes \ into / which is the right thing, but as a side effect, it applies the same fix to URLs. Which again could be a good thing because Chrome browser does exactly the same thing.

There is an inconsistency in behaviour between OSes with fileseparator = \ and other Oses. I don't know if it should be fixed.

@bradfitz bradfitz added this to the Go1.11 milestone Mar 4, 2018

@bradfitz

This comment has been minimized.

Member

bradfitz commented Mar 4, 2018

I'm pretty sure we should fix this, but marking it as needs decision just in case. @ianlancetaylor, @rsc?

@rsc

This comment has been minimized.

Contributor

rsc commented Mar 26, 2018

I agree.

@spf13 spf13 added the NeedsFix label Mar 26, 2018

@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Go1.12 Jul 2, 2018

@bcmills

This comment has been minimized.

Member

bcmills commented Oct 24, 2018

The fact that the backslashes work on Windows is intentional and not actually Windows-specific:

// Arguments are supposed to be import paths, but
// as a courtesy to Windows developers, rewrite \ to /
// in command-line arguments. Handles .\... and so on.
if filepath.Separator == '\\' {
a = strings.ReplaceAll(a, `\`, `/`)
}

We should figure out why they don't work on macOS.

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Oct 24, 2018

@bcmills bcmills changed the title from cmd/go: "go get github.com\alexbrainman\gowingui" should fail to cmd/go: "go get github.com\alexbrainman\gowingui" should succeed on Mac Oct 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment