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: dependency only used in test code can not be found #31992

Closed
cloudfstrife opened this issue May 13, 2019 · 3 comments
Closed

cmd/go: dependency only used in test code can not be found #31992

cloudfstrife opened this issue May 13, 2019 · 3 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@cloudfstrife
Copy link

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

$ go version
go version go1.12.5 windows/amd64

Does this issue reproduce with the latest release?

I use the latest version

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

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Cloud.F.Strife\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\go\env
set GOPROXY=
set GORACE=
set GOROOT=D:\go
set GOTMPDIR=
set GOTOOLDIR=D:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\space\testing\go.mod
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\CLOUDF~1.STR\AppData\Local\Temp\go-build307206806=/tmp/go-build -gno-record-gcc-switches

What did you do?

testing code is this

.
|-- fibonacci
|   |-- fibonacci.go
|   `-- fibonacci_test.go
|-- go.mod
`-- go.sum

go.mod file

module app/testing

go 1.12

require github.com/google/go-cmp v0.3.0 // indirect

fibonacci.go do not import any module

fibonacci/fibonacci_test.go import github.com/google/go-cmp

package fibonacci

import (
        "fmt"
        "testing"

        "github.com/google/go-cmp"
)

when i run go test -v app/testing/fibonacci , i got an error:

$ go test -v app/testing/fibonacci
# app/testing/fibonacci
fibonacci\fibonacci_test.go:7:2: unknown import path "github.com/google/go-cmp": cannot find module providing package github.com/google/go-cmp
FAIL    app/testing/fibonacci [setup failed]

when i run go mod tidy , the go-cmp dependency in go.mod disappeared

What did you expect to see?

did i use go module in wrong way ? what can i do to resolve this problem?

What did you see instead?

@andybons andybons changed the title module:dependency only used in test code can not be found cmd/go: dependency only used in test code can not be found May 13, 2019
@andybons andybons added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 13, 2019
@andybons andybons added this to the Unplanned milestone May 13, 2019
@andybons
Copy link
Member

@jayconrod @bcmills

@jayconrod
Copy link
Contributor

I think you meant to import github.com/google/go-cmp/cmp? There is no package with the path github.com/google/go-cmp, though that is the correct module path.

The error message could be a bit clearer. #30723 is the main issue for that.

@cloudfstrife
Copy link
Author

thanks a lot

@golang golang locked and limited conversation to collaborators May 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants