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: main package in GoPath/src/ runs "go install" fail. #22863

Closed
vipally opened this issue Nov 24, 2017 · 4 comments
Closed

cmd/go: main package in GoPath/src/ runs "go install" fail. #22863

vipally opened this issue Nov 24, 2017 · 4 comments

Comments

@vipally
Copy link

vipally commented Nov 24, 2017

Please answer these questions before submitting your issue. Thanks!

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

Go1.9

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 GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\gocode
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\dai
zejun\AppData\Local\Temp\go-build824272051=/tmp/go-build -gno-record-gcc-switche
s
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

What did you do?

Create a hello world main package in GoPath/src.And run "go install"

package main
func main(){
println("hello world!")
}

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

"go install" runs well, and install in GoPath/bin.

What did you see instead?

go install: no install location for directory E:\gocode\src outside GOPATH
For more details see: 'go help gopath'

@vipally vipally changed the title cmd/go: "go install" of main package in GoPath/src doesn't work. cmd/go: main package in GoPath/src/ runs "go install" fail. Nov 24, 2017
@davecheney
Copy link
Contributor

davecheney commented Nov 24, 2017 via email

@cznic
Copy link
Contributor

cznic commented Nov 24, 2017

For go install to work the package must live under, not in $GOPATH/src which is what the error message says.

vipally added a commit to vipally/go that referenced this issue Nov 24, 2017
@vipally
Copy link
Author

vipally commented Nov 24, 2017

I have made a patch to fix this case:
vipally@fa56999
https://github.com/vipally/go/tree/issue_22863
For your information, thanks.

vipally added a commit to vipally/go that referenced this issue Nov 24, 2017
fix issue golang#22863: cmd/go: main package in GoPath/src/ runs "go install" fail.
@bradfitz
Copy link
Contributor

This is working as intended. Its name can't be inferred if it's at the root of $GOPATH/src. It needs a directory under that to get a name.

vipally added a commit to vipally/go that referenced this issue Nov 24, 2017
@golang golang locked and limited conversation to collaborators Nov 24, 2018
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

5 participants