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: confusing type mismatch error for different import paths #25174

Closed
jasontconnell opened this issue Apr 30, 2018 · 5 comments
Closed

cmd/go: confusing type mismatch error for different import paths #25174

jasontconnell opened this issue Apr 30, 2018 · 5 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@jasontconnell
Copy link

jasontconnell commented Apr 30, 2018

I apologize for the title.

Please answer these questions before submitting your issue. Thanks!

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

1.10.1

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\jconnell\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\jconnell\Documents\go
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\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\jconnell\AppData\Local\Temp\go-build705894178=/tmp/go-build -gno-record-gcc-switches

What did you do?

Imported (via dep) my dependency which is structure as
github.com/jasontconnell/testuuid/api
github.com/jasontconnell/testuuid/other
With code in each of those sub-packages referencing another external dependency ( github.com/google/uuid )

Repo to reproduce issue is here - https://github.com/jasontconnell/uuiddep
Git clone, dep ensure (v 0.4.1), Go build. There's a chance dep could be to blame here, but the files seem to be in vendor folder correctly.

What did you expect to see?

Build success

What did you see instead?

uuiddep/vendor/github.com/jasontconnell/testuuid/other
vendor\github.com\jasontconnell\testuuid\other\other.go:15:30: cannot use idh.ID (type "testuuid/vendor/github.com/google/uuid".UUID) as type "uuiddep/vendor/github.com/google/uuid".UUID in field value

@agnivade
Copy link
Contributor

agnivade commented Apr 30, 2018

Seems like a normal compiler type mismatch error to me.

You are importing "testuuid/api" in one file. But importing "github.com/jasontconnell/testuuid/api" in your target project. Most probably this is messing up the type checks. Try changing all import paths to be consistent.

@jasontconnell
Copy link
Author

Yes it appears that the local import does not work when included as a dependency. I've exclusively used local imports and I see the error in my ways. This works as designed.

@jasontconnell
Copy link
Author

However, the error message was confusing and was very difficult to track down the issue because of it. If that could be edited to be more useful and telling of the actual problem, it'd help out future developers and prevent more bug reports like this one. So I will reopen it and report that that is the issue now.

@jasontconnell jasontconnell reopened this Apr 30, 2018
@agnivade agnivade changed the title Go Build with dependency which has sub-packages which reference another dependency cmd/go: confusing type mismatch error for different import paths Apr 30, 2018
@agnivade
Copy link
Contributor

IMO, the error message is clear enough.

cannot use idh.ID (type "testuuid/vendor/github.com/google/uuid".UUID) as type "uuiddep/vendor/github.com/google/uuid".UUID in field value

clearly shows that the import paths are different, hence points to an issue in that area.

However, I will leave it to others for a final decision.

/cc @ianlancetaylor

@agnivade agnivade added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Apr 30, 2018
@agnivade agnivade added this to the Go1.11 milestone Apr 30, 2018
@jasontconnell
Copy link
Author

@agnivade I agree, knowing the issue now, the error message makes more sense, and I will know what it means going forward.

jasontconnell pushed a commit to jasontconnell/sitecore that referenced this issue Apr 30, 2018
@golang golang locked and limited conversation to collaborators Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants