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: multiple gopath has the same code cause of build fail #16534

Closed
wangxingge opened this issue Jul 29, 2016 · 3 comments
Closed

cmd/go: multiple gopath has the same code cause of build fail #16534

wangxingge opened this issue Jul 29, 2016 · 3 comments
Milestone

Comments

@wangxingge
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6.2 windows/amd64
  2. What operating system and processor architecture are you using (go env)?
    windows64, i7
  3. What did you do?
    First of all, my go path like following(on my computer)

Golang source code
----|---------C:\Go
----|--------------\bin
----|--------------\pkg
----|--------------\src

open source code
----|---------D:\opensource
----|----------------------\bin
----|----------------------\pkg
----|----------------------\src

master code branch (master)
----|---------D:\master
----|------------------\bin
----|------------------\pkg
----|------------------\src\customer.com\project_a

released code branch
----|---------D:\released
----|--------------------\v1
----|-----------------------\bin
----|-----------------------\pkg
----|-----------------------\src\customer.com\project_a
----|--------------------\v2
----|-----------------------\bin
----|-----------------------\pkg
----|-----------------------\src\customer.com\project_a

I'm working on master branch, and it's ok now, i can build, install, debug it.

I'll create a tag as the relase code after code complete, like v1 or v1-x.
Sometimes we need to add or merge functions to released branch(v1 or v2) then build and publish.

When i build code(in released folder), got error: .\main.go:12: dp.NewProp undefined (type dpack.DpackObject has no field or method NewProp).
I know this cause of the type in package does not contain such property, so i'm trying to install the package(in released folder).
Then got error: go install: no install location for D:\released\v1\src\wangxingge.com\Console\dpack: hidden by D:\master\src\wangxingge.com\Console\dpack.
That's mean released source code using master pkg, cause of import code was the same in all gopath.

  1. What did you expect to see?
    Build pass and use the right package.
    My question is how to use the current path package when build or install correct.
  2. What did you see instead?
@quentinmit
Copy link
Contributor

I don't follow what's going on, please provide the complete output of "go env" as requested.

@rakyll rakyll changed the title Multiple gopath has the same code cause of build fail. cmd/go: multiple gopath has the same code cause of build fail Jul 29, 2016
@rakyll rakyll added this to the Go1.8 milestone Jul 29, 2016
@wangxingge
Copy link
Author

@quentinmit
thanks for your reply, following my go env.
C:\Users\WangXingGe>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\opensource;D:\master;D:\released\v1
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

btw, i create a virtual machine to build released code, is there other way?

@quentinmit
Copy link
Contributor

So, GOPATH specifies the order in which packages should be found. Since you have src\customer.com\project_a in D:\master, that is hiding the src\customer.com\project_a that you have in D:\released\v1. If you want to build the package in D:\released\v1, you need to remove D:\master from your search path.

I don't believe there's any bug in the go command here.

@golang golang locked and limited conversation to collaborators Oct 6, 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

4 participants