Go version
go version go1.23.1 linux/arm64
Output of go env in your module/workspace:
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/home/ayke/.cache/go-build'
GOENV='/home/ayke/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/ayke/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ayke'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go1.23.1'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go1.23.1/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ayke/.config/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3054841504=/tmp/go-build -gno-record-gcc-switches'
What did you do?
I have the following invalid Go file
package main
import _ "#"
func main() {
}
I ran go list -json -e importpath.go on it, to see the loader error.
What did you see happen?
The JSON contains this part:
"Error": {
"ImportStack": [],
"Pos": "",
"Err": "/home/ayke/tmp/importpath.go:3:8: invalid import path: #"
}
That's an error, of course, but the Pos field is not set even though go list clearly knows the source location (it's stored in the error message itself).
What did you expect to see?
I expected an output like this:
"Error": {
"ImportStack": [],
"Pos": "importpath.go:3:8",
"Err": "invalid import path: #"
}
That is, the position information should be in Pos and the path should be relative and not absolute. For example, when setting the import path to one that doesn't exist, the error looks like this:
"Error": {
"ImportStack": [
"command-line-arguments"
],
"Pos": "importpath.go:3:8",
"Err": "no required module provides package foo.bar: go.mod file not found in current directory or any parent directory; see 'go help modules'"
}
Go version
go version go1.23.1 linux/arm64
Output of
go envin your module/workspace:What did you do?
I have the following invalid Go file
I ran
go list -json -e importpath.goon it, to see the loader error.What did you see happen?
The JSON contains this part:
That's an error, of course, but the
Posfield is not set even thoughgo listclearly knows the source location (it's stored in the error message itself).What did you expect to see?
I expected an output like this:
That is, the position information should be in
Posand the path should be relative and not absolute. For example, when setting the import path to one that doesn't exist, the error looks like this: