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/vet: gives errors about import paths when used on test files in Windows #24587
Comments
^ Those methods exist in a different test file in the same dir/package. All my tests in all these files run and succeed perfectly fine. |
Is there a good and easy way to reproduce and test fixes for these things while on a different operating system? Other than running a virtual machine, that is. |
Is there a way that we can recreate the problems ourselves? Are the vet errors correct? Or do the files contain forward slashes although vet is complaining about backslashes? |
Sorry for not posting a short way to reproduce this, I did not have the time yesterday but wanted to put the bug in before I forgot. Here is a short way to reproduce, even if it is a bit contrived: Create the following files, then also download
package vet_bug
func Add(a, b int) int {
return a + b
}
package vet_bug
import (
"testing"
)
func TestAdd(t *testing.T) {
inouts := []struct {
a int
b int
r int
}{
{a: 0, b: 0, r: 0},
{a: 1, b: 1, r: 2},
{a: 3, b: 5, r: 8},
}
for _, inout := range inouts {
AssertEqual(t, inout.r, Add(inout.a, inout.b))
}
}
package vet_bug
import (
"fmt"
"testing"
"github.com/aws/aws-sdk-go/aws"
)
func AssertEqual(tb testing.TB, expected, actual int) {
tb.Helper()
// Pointless, but gives us an error in `go vet`
config := aws.Config{}
fmt.Println(config)
if expected != actual {
tb.Error("Expected:", expected, "; Got:", actual)
}
} When running
When running
Here are the contents of the file it is referencing: https://github.com/aws/aws-sdk-go/blob/master/aws/config.go package aws
import (
"net/http"
"time"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/endpoints"
)
// The rest of the file... The tests pass. I would also love if someone could tell me what the difference is between |
The difference between After you follow the instructions you describe, what does the start of vendor\github.com\aws\aws-sdk-go\aws\config.go look like on your system? On my system it does not contain any backslashes: package aws
import (
"net/http"
"time"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/endpoints"
) When you say "run go vet on the file x.go" what precisely are you typing? |
I have the exact same as you for the top portion of that config file. Here is git-bash terminal showing the issue: MinGW 04:40:14 ~/workspace/go/src/github.com/veqryn/personal/src/vet_bug$ go vet ./vet_bug_test.go
# command-line-arguments
.\vet_bug_test.go:19:3: undefined: AssertEqual
.\vet_bug_test.go:19:27: undefined: Add
MinGW 04:40:25 ~/workspace/go/src/github.com/veqryn/personal/src/vet_bug$ go vet ./util_test.go
# github.com\veqryn\personal/vendor/github.com/aws/aws-sdk-go/aws
..\..\vendor\github.com\aws\aws-sdk-go\aws\config.go:7:2: import path contains backslash; use slash: "github.com\\veqryn\\personal/vendor/github.com/aws/aws-sdk-go/aws/awserr"
..\..\vendor\github.com\aws\aws-sdk-go\aws\config.go:7:2: cannot import "github.com\\veqryn\\personal/vendor/github.com/aws/aws-sdk-go/aws/credentials" due to version skew - reinstall package (bad package path "github.com\\veqryn\\personal/vendor/github.com/aws/aws-sdk-go/aws/awserr" for package awserr) Here is good old cmd.exe showing the same issue: C:\Users\cduncan\workspace\go\src\github.com\veqryn\personal\src\vet_bug>go vet .\vet_bug_test.go
# command-line-arguments
.\vet_bug_test.go:19:3: undefined: AssertEqual
.\vet_bug_test.go:19:27: undefined: Add
C:\Users\cduncan\workspace\go\src\github.com\veqryn\personal\src\vet_bug>go vet .\util_test.go
# github.com\veqryn\personal/vendor/github.com/aws/aws-sdk-go/aws
..\..\vendor\github.com\aws\aws-sdk-go\aws\config.go:7:2: import path contains backslash; use slash: "github.com\\veqryn\\personal/vendor/github.com/aws/aws-sdk-go/aws/awserr"
..\..\vendor\github.com\aws\aws-sdk-go\aws\config.go:7:2: cannot import "github.com\\veqryn\\personal/vendor/github.com/aws/aws-sdk-go/aws/credentials" due to version skew - reinstall package (bad package path "github.com\\veqryn\\personal/vendor/github.com/aws/aws-sdk-go/aws/awserr" for package awserr)
C:\Users\cduncan\workspace\go\src\github.com\veqryn\personal\src\vet_bug>
C:\Users\cduncan\workspace\go\src\github.com\veqryn\personal\src\vet_bug>cat ..\..\vendor\github.com\aws\aws-sdk-go\aws\config.go
package aws
import (
"net/http"
"time"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/endpoints"
)
// UseServiceDefaultRetries instructs the config to use the service's own |
In Go 1.10, you generally should not run But I am at a loss as to why you are seeing what you are seeing. Can anyone else recreate the problem? |
If you run go vet on a package instead of a file, will it vet your test files too? I believe this error would only occur on Windows, since it is related to the slash vs backslash. go vet did work without these errors on 1.9.x |
Yes. |
If I follow instructions as per #24587 (comment) I can reproduce the problem:
I did not have time to investigate why this is happening. Alex |
The error messages |
This seems to be "fixed" on master now. I bisected fix to a3c75d9 I have no explanation why this commit "fixes" the issue. For still broken ca2f85f I can see this:
For fixed a3c75d9 I can see:
Alex |
Optimistically closing as fixed based on previous comment. |
What version of Go are you using (
go version
)?go version go1.10 windows/amd64
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\cduncan\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\cduncan\workspace\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=-IC:\Users\cduncan\workspace\programs\oracle\windows\instantclient_12_1\sdk\include
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-LC:\Users\cduncan\workspace\programs\oracle\windows\instantclient_12_1 -loci
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\cduncan\AppData\Local\Temp\go-build922471030=/tmp/go-build -gno-record-gcc-switches
What did you do?
I have a file and some tests.
All third party code has been vendored into the vendor directory using go
dep
version v0.4.1The tests have these imports:
What did you expect to see?
With Golang 1.9.2 (my previous version),
go vet
gave me an 'all clear'.The files and the tests also compile and run perfectly fine.
What did you see instead?
Also to note:
go tool vet
doesn't return anything. I'm still not sure what the difference between them is.And go vet on the non-test file (
go vet C:\Users\cduncan\workspace\go\src\github.com\ReturnPath\ecm\services\pixel_server\pixel_server.go
) returns an all clearThe text was updated successfully, but these errors were encountered: