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: fullpath always enabled in GOPATH mode #69500

Closed
rittneje opened this issue Sep 17, 2024 · 4 comments
Closed

cmd/go: fullpath always enabled in GOPATH mode #69500

rittneje opened this issue Sep 17, 2024 · 4 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rittneje
Copy link

Go version

go version go1.22.6 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOCACHE='/tmp/.gocache'
GOENV='/Users/rittneje/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/rittneje/go/pkg/mod'
GONOPROXY='[REDACTED]'
GONOSUMDB='[REDACTED]'
GOOS='darwin'
GOPATH='/Users/rittneje/go'
GOPRIVATE='[REDACTED]'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/rittneje/go1.22.6'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/Users/rittneje/go1.22.6/pkg/tool/darwin_amd64'
GOVCS='[REDACTED]'
GOVERSION='go1.22.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='[REDACTED]'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/kf/kr7_s3xx0l12zbj3jrn082hmzy5gvy/T/go-build561042032=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I ran go test in GOPATH mode (i.e., GO111MODULE=auto) without -fullpath.

What did you see happen?

The errors included full (absolute) paths.

What did you expect to see?

I expected to see relative paths.

If this behavior is intentional, it should be explicitly noted in the documentation for the -fullpath flag. https://pkg.go.dev/cmd/go#hdr-Test_packages

This also was not mentioned in the 1.21 release notes on the matter. https://tip.golang.org/doc/go1.21#go-command

I'll also note that even explicitly passing -fullpath=false doesn't disable it.

@cagedmantis cagedmantis added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Sep 17, 2024
@cagedmantis cagedmantis added this to the Backlog milestone Sep 17, 2024
@cagedmantis
Copy link
Contributor

cc @matloob @samthanawalla

@matloob
Copy link
Contributor

matloob commented Sep 17, 2024

Hi @rittneje, could you help me reproduce this? This is what I tried:

[~]$ go install golang.org/dl/go1.22.6@latest 
[~]$ go1.22.6 download
go1.22.6: already downloaded in /Users/matloob/sdk/go1.22.6
[~]$ export GOPATH=$HOME/Desktop/issue69500
[~]$ export GO111MODULE=auto
[~]$ echo "" | txtar Desktop/issue69500
-- Desktop/issue69500/src/example.com/foo/foo_test.go --
package foo

import "testing"

func TestFoo(t *testing.T) {
	t.Errorf("this is an error")
}
[~]$ go1.22.6 test -fullpath example.com/foo
--- FAIL: TestFoo (0.00s)
    /Users/matloob/Desktop/issue69500/src/example.com/foo/foo_test.go:6: this is an error
FAIL
FAIL	example.com/foo	0.185s
FAIL
[~]$ go1.22.6 test example.com/foo        
--- FAIL: TestFoo (0.00s)
    foo_test.go:6: this is an error
FAIL
FAIL	example.com/foo	0.195s
FAIL
[~]$ go1.22.6 test -fullpath=false example.com/foo
--- FAIL: TestFoo (0.00s)
    foo_test.go:6: this is an error
FAIL
FAIL	example.com/foo	0.181s
FAIL

(I'm using the txtar command to dump the contents of the foo_test.go file)

@rittneje
Copy link
Author

@matloob For some strange reason, it only does this if you do "run test" in VS Code. I can't figure out why - I've try printing out os.Args from the test and then running that directly, and even that doesn't reproduce it.

I'm going to re-file this over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go 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