admin管理员组

文章数量:1244304

I recently started using an M1 MacBook and set up the Go environment. I have installed Go, Delve (Dlv), and gopls. Here is my environment setup:

$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/ryan/Library/Caches/go-build"
GOENV="/Users/ryan/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ryan/go/pkg/mod"
GONOPROXY="*.xlcx.work"
GONOSUMDB="*.xlcx.work"
GOOS="darwin"
GOPATH="/Users/ryan/go"
GOPRIVATE="*.xlcx.work"
GOPROXY=",direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.12"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yt/pk31kvcj3yjfr488_7qv5t9h0000gn/T/go-build2846723005=/tmp/go-build -gno-record-gcc-switches -fno-common"

$ gopls version
golang/x/tools/gopls v0.15.3

$ dlv version
Delve Debugger
Version: 1.22.1
Build: $Id: 0c3470054da6feac5f6dcf3e3e5144a64f7a9a48 $

I use VSCode to develop my project. I have two Go projects. When I start the first project, gopls loads the package successfully, and I can jump to definitions without any issues. Here is the gopls log for the first project:

[Info  - 12:35:35] 2025/02/16 12:35:35 go info for /Users/ryan/develop/serviceA
(view type GoModView)
(root dir /Users/ryan/develop/serviceA)
(go version go version go1.20.12 darwin/arm64)
(build flags: [])
(go env: {GOOS:darwin GOARCH:arm64 GOCACHE:/Users/ryan/Library/Caches/go-build GOMODCACHE:/Users/ryan/go/pkg/mod GOPATH:/Users/ryan/go GOPRIVATE:*.xlcx.work GOFLAGS: GO111MODULE: GoVersion:20 GoVersionOutput:go version go1.20.12 darwin/arm64
 GOWORK: GOPACKAGESDRIVER:})
(env overlay: map[])


[Info  - 12:35:40] 2025/02/16 12:35:40 go/packages.Load #1
    snapshot=0
    directory=file:///Users/ryan/develop/serviceA
    query=[/Users/ryan/develop/serviceA/... builtin]
    packages=123

[Info  - 12:35:40] 2025/02/16 12:35:40 go/packages.Load #1: updating metadata for 781 packages

[Error - 12:35:44] Request textDocument/semanticTokens/full failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:35:44] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:35:44] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:35:46] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:35:49] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:36:02] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:36:03] Request textDocument/semanticTokens/full failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:36:04] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
[Error - 12:36:06] Request textDocument/semanticTokens/range failed.
  Message: semantictokens are disabled
  Code: 0 
[Info  - 12:36:15] 2025/02/16 12:36:15 background imports cache refresh starting

[Info  - 12:36:16] 2025/02/16 12:36:16 background refresh finished after 2.365305791s

However, when I start the second project, gopls loads the package very slowly and seems to be blocked. Additionally, I can’t jump to definitions. Despite this, I can’t find any error logs in the gopls log. Here is the gopls log for the second project:

[Info  - 12:38:01] 2025/02/16 12:38:01 go info for /Users/ryan/develop/serviceB
(view type GoModView)
(root dir /Users/ryan/develop/serviceB)
(go version go version go1.20.12 darwin/arm64)
(build flags: [])
(go env: {GOOS:darwin GOARCH:arm64 GOCACHE:/Users/ryan/Library/Caches/go-build GOMODCACHE:/Users/ryan/go/pkg/mod GOPATH:/Users/ryan/go GOPRIVATE:*.xlcx.work GOFLAGS: GO111MODULE: GoVersion:20 GoVersionOutput:go version go1.20.12 darwin/arm64
 GOWORK: GOPACKAGESDRIVER:})
(env overlay: map[])


[Info  - 12:38:01] 2025/02/16 12:38:01 8.485ms for GOROOT= GOPATH=/Users/ryan/go GO111MODULE=off GOPROXY=,direct PWD=/Users/ryan/develop/serviceB go list -e -f {{context.ReleaseTags}} -- unsafe

[Info  - 12:38:01] 2025/02/16 12:38:01 13.158917ms for GOROOT= GOPATH=/Users/ryan/go GO111MODULE=auto GOPROXY=,direct PWD=/Users/ryan/develop/serviceB go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe

What steps should I take to resolve this?

Thank you!

Loads package successfully and can jump to deferences.

本文标签: gogopls Loading Package Blocked and Can’t Jump to DefinitionStack Overflow