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
Comments
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. |
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. |
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. |
IMO, the error message is clear enough.
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 I agree, knowing the issue now, the error message makes more sense, and I will know what it means going forward. |
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
The text was updated successfully, but these errors were encountered: