Skip to content

cmd/go: can't invoke go in src directory #67853

Not planned
@j2gg0s

Description

@j2gg0s

Go version

go version go1.22.4 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/j2gg0s/Library/Caches/go-build'
GOENV='/Users/j2gg0s/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/j2gg0s/go/pkg/mod'
GONOPROXY='dev.msh.team,ohai.bot,github.com/j2gg0s'
GONOSUMDB='dev.msh.team,ohai.bot,github.com/j2gg0s'
GOOS='darwin'
GOPATH='/Users/j2gg0s/go'
GOPRIVATE='dev.msh.team,ohai.bot,github.com/j2gg0s'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/j2gg0s/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/j2gg0s/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/j2gg0s/go/src/github.com/j2gg0s/gist/vimgo/go.mod'
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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/3g/291pfdd54f11rlb15_hbq1dr0000gn/T/go-build2108187988=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Call GoDef in vim-go with Go>=1.22

What did you see happen?

When invoke the go in src, it fails to execute because it can't infer then correct version.

➜  json pwd
/Users/j2gg0s/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/encoding/json
➜  json go env GOMOD
go: downloading go1.22 (darwin/arm64)
go: download go1.22 for darwin/arm64: toolchain not available

vim-go and others will switch to the target directory to execute relevant commands, such as go env, before invoking gopls.
Link issue: fatih/vim-go#3669

What did you expect to see?

In the src files download by toolchain, change the version in go.mod from go1.22 to go1.22.x

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gopherbot@seankhliao@j2gg0s

        Issue actions

          cmd/go: can't invoke go in src directory · Issue #67853 · golang/go