go: cmd/go: `expected 'package', found 'EOF'` errors with module indexing enabled on WSL2

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

$ go version
go version go1.19 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jhaumont/.cache/go-build"
GOENV="/home/jhaumont/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jhaumont/go/pkg/mod"
GONOPROXY="github.com/blablacar"
GONOSUMDB="github.com/blablacar"
GOOS="linux"
GOPATH="/home/jhaumont/go"
GOPRIVATE="github.com/blablacar"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jhaumont/bin/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jhaumont/bin/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1850192189=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When installing 1.19 go version & reinstall/update the additional go tools like gopls & dlv, I have an issue with delve and the package https://github.com/hashicorp/golang-lru/tree/master/simplelru. So, I can’t install delve. But if I use the 1.18.5 version of go, I have no issue and I can install the last delve version (1.9.0)

But if I use GODEBUG=goindex=0, it works 😃

Reproduce: I try to do a fresh install of go (with 1.19.0) and then, install delve.

  • Install go:
rm -rf ${HOME}/bin/go
cd "$(mktemp -d)"
wget https://go.dev/dl/go1.19.linux-amd64.tar.gz
tar -C ${HOME}/bin -xzf go1.19.linux-amd64.tar.gz
  • Install devel:
go install -v github.com/go-delve/delve/cmd/dlv@latest

What did you expect to see?

No error, devel is correctly installed

What did you see instead?

pkg/mod/github.com/hashicorp/golang-lru@v0.5.4/simplelru/lru.go:1:1: expected 'package', found 'EOF'

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 24 (6 by maintainers)

Most upvoted comments

The problem has been resolved after I deleted go-build cache in ~/.cache/go-build

This is currently the only report we have of this kind of corruption. It’s not clear to me whether this is a bug in Go, a bug in WSL2, or both. Moving to the Backlog pending more user reports and/or test failures that might shed some light for debugging.

@bcmills I’m on WSL. This is the result of mount | column -t command: /dev/sdc on / type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered) And for the second question, the answer is no (I already test it before opening the issue)

Hello I face the same issue with 2 new packages (not link to delve) on an internal go projet: ../../go/pkg/mod/github.com/armon/go-radix@v1.0.0/radix.go:1:1: expected 'package', found 'EOF' ../../go/pkg/mod/github.com/mitchellh/mapstructure@v1.5.0/decode_hooks.go:1:1: expected 'package', found 'EOF' Using GODEBUG=goindex=0 fix the issue