为什么我在通过VScode安装gopls时会出错

7rtdyuoh  于 2023-05-27  发布在  Go
关注(0)|答案(1)|浏览(760)

我开始学习Go,并希望设置环境enter image description here
这一切都始于安装VScode的扩展。我犯了一个巨大的错误:

Tools environment: GOPATH=C:\Users\DNS\go
Installing 1 tool at C:\Users\DNS\go\bin in module mode.
  gopls

Installing golang.org/x/tools/gopls@latest FAILED
{
 "code": 1,
 "killed": false,
 "signal": null,
 "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v golang.org/x/tools/gopls@latest",
 "stdout": "",
 "stderr": "golang.org/x/exp/slices\ngolang.org/x/vuln/osv\ngithub.com/google/go-cmp/cmp/internal/diff\ngolang.org/x/tools/internal/event/keys\ngolang.org/x/mod/module\ngolang.org/x/tools/gopls/internal/span\ngolang.org/x/tools/go/analysis/passes/buildtag\ngolang.org/x/tools/go/analysis/passes/cgocall\ngolang.org/x/tools/go/analysis/passes/asmdecl\n# github.com/google/go-cmp/cmp/internal/diff\n..\\..\\..\\..\\go\\pkg\\mod\\github.com\\google\\go-cmp@v0.5.9\\cmp\\internal\\diff\\diff.go:19:2: could not import github.com/google/go-cmp/cmp/internal/flags (EOF)\n# golang.org/x/vuln/osv\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\vuln@v0.0.0-20221109205719-3af8368ee4fe\\osv\\json.go:19:7: could not import golang.org/x/vuln/internal/semver (EOF)\ngolang.org/x/tools/go/internal/cgo\ngolang.org/x/tools/go/ast/inspector\n# golang.org/x/exp/slices\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\slices.go:15:8: could not import golang.org/x/exp/constraints (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\slices.go:68:8: invalid operation: v1 < v2 (type parameter E is not comparable with <)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\slices.go:70:8: invalid operation: v1 > v2 (type parameter E is not comparable with >)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\sort.go:42:6: invalid operation: x[i] < x[i - 1] (type parameter E is not comparable with <)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\sort.go:68:50: invalid operation: x[i] >= target (type parameter E is not comparable with >=)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\sort.go:69:22: invalid operation: x[pos] != target (incomparable types in type set)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\zsortordered.go:14:25: invalid operation: data[j] < data[j - 1] (type parameter E is not comparable with <)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\zsortordered.go:29:23: invalid operation: data[first + child] < data[first + child + 1] (type parameter E is not comparable with <)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\zsortordered.go:32:8: invalid operation: data[first + root] < data[first + child] (type parameter E is not comparable with <)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\zsortordered.go:110:17: invalid operation: data[a - 1] < data[pivot] (type parameter E is not comparable with <)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\exp@v0.0.0-20221031165847-c99f073a8326\\slices\\zsortordered.go:110:17: too many errors\ngolang.org/x/tools/go/ast/astutil\ngolang.org/x/tools/go/analysis/passes/tests\ngolang.org/x/tools/internal/gcimporter\n# golang.org/x/tools/internal/event/keys\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\event\\keys\\keys.go:13:2: could not import golang.org/x/tools/internal/event/label (EOF)\ngolang.org/x/vuln/vulncheck/internal/gosym\n# golang.org/x/mod/module\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\mod@v0.7.0\\module\\pseudo.go:43:2: could not import golang.org/x/mod/internal/lazyregexp (EOF)\ngolang.org/x/tools/gopls/internal/lsp/analysis/embeddirective\ndebug/buildinfo\n# golang.org/x/tools/gopls/internal/span\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools\\gopls@v0.11.0\\internal\\span\\token.go:11:2: could not import golang.org/x/tools/internal/bug (EOF)\nhonnef.co/go/tools/analysis/lint\n# golang.org/x/tools/go/analysis/passes/buildtag\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\buildtag\\buildtag.go:19:2: could not import golang.org/x/tools/go/analysis (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\buildtag\\buildtag.go:20:2: could not import golang.org/x/tools/go/analysis/passes/internal/analysisutil (EOF)\nhonnef.co/go/tools/analysis/facts/generated\n# golang.org/x/tools/go/internal/cgo\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\internal\\cgo\\cgo.go:67:7: could not import golang.org/x/sys/execabs (EOF)\nhonnef.co/go/tools/analysis/facts/tokenfile\n# golang.org/x/tools/go/analysis/passes/cgocall\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\cgocall\\cgocall.go:20:2: could not import golang.org/x/tools/go/analysis (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\cgocall\\cgocall.go:21:2: could not import golang.org/x/tools/go/analysis/passes/internal/analysisutil (EOF)\n# golang.org/x/tools/go/ast/inspector\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\ast\\inspector\\typeof.go:16:2: could not import golang.org/x/tools/internal/typeparams (EOF)\n# golang.org/x/tools/go/analysis/passes/asmdecl\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\asmdecl\\asmdecl.go:21:2: could not import golang.org/x/tools/go/analysis (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\asmdecl\\asmdecl.go:22:2: could not import golang.org/x/tools/go/analysis/passes/internal/analysisutil (EOF)\nhonnef.co/go/tools/analysis/facts/deprecated\nhonnef.co/go/tools/analysis/edit\n# golang.org/x/tools/gopls/internal/lsp/analysis/embeddirective\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools\\gopls@v0.11.0\\internal\\lsp\\analysis\\embeddirective\\embeddirective.go:12:2: could not import golang.org/x/tools/go/analysis (EOF)\nhonnef.co/go/tools/config\n# golang.org/x/tools/go/analysis/passes/tests\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\tests\\tests.go:19:2: could not import golang.org/x/tools/go/analysis (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\tests\\tests.go:20:2: could not import golang.org/x/tools/internal/analysisinternal (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\analysis\\passes\\tests\\tests.go:21:2: could not import golang.org/x/tools/internal/typeparams (EOF)\n# golang.org/x/tools/go/ast/astutil\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\go\\ast\\astutil\\enclosing.go:15:2: could not import golang.org/x/tools/internal/typeparams (EOF)\ngolang.org/x/tools/internal/memoize\n# golang.org/x/vuln/vulncheck/internal/gosym\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\vuln@v0.0.0-20221109205719-3af8368ee4fe\\vulncheck\\internal\\gosym\\sym.go:11:2: could not import golang.org/x/vuln/internal/semver (EOF)\ngolang.org/x/tools/gopls/internal/lsp/browser\n# honnef.co/go/tools/analysis/facts/generated\n..\\..\\..\\..\\go\\pkg\\mod\\honnef.co\\go\\tools@v0.3.3\\analysis\\facts\\generated\\generated.go:11:2: could not import golang.org/x/tools/go/analysis (EOF)\n# debug/buildinfo\nC:\\Program Files\\Go\\src\\debug\\buildinfo\\buildinfo.go:18:2: could not import debug/plan9obj (EOF)\n# honnef.co/go/tools/analysis/lint\n..\\..\\..\\..\\go\\pkg\\mod\\honnef.co\\go\\tools@v0.3.3\\analysis\\lint\\lint.go:14:2: could not import golang.org/x/tools/go/analysis (EOF)\n# honnef.co/go/tools/analysis/facts/tokenfile\n..\\..\\..\\..\\go\\pkg\\mod\\honnef.co\\go\\tools@v0.3.3\\analysis\\facts\\tokenfile\\token.go:8:2: could not import golang.org/x/tools/go/analysis (EOF)\n# honnef.co/go/tools/analysis/edit\n..\\..\\..\\..\\go\\pkg\\mod\\honnef.co\\go\\tools@v0.3.3\\analysis\\edit\\edit.go:10:2: could not import golang.org/x/tools/go/analysis (EOF)\n# honnef.co/go/tools/config\n..\\..\\..\\..\\go\\pkg\\mod\\honnef.co\\go\\tools@v0.3.3\\config\\config.go:14:2: could not import golang.org/x/tools/go/analysis (EOF)\n# golang.org/x/tools/internal/memoize\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\memoize\\memoize.go:29:2: could not import golang.org/x/tools/internal/xcontext (EOF)\n# honnef.co/go/tools/analysis/facts/deprecated\n..\\..\\..\\..\\go\\pkg\\mod\\honnef.co\\go\\tools@v0.3.3\\analysis\\facts\\deprecated\\deprecated.go:10:2: could not import golang.org/x/tools/go/analysis (EOF)\n# golang.org/x/tools/gopls/internal/lsp/browser\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools\\gopls@v0.11.0\\internal\\lsp\\browser\\browser.go:9:7: could not import golang.org/x/sys/execabs (EOF)\n# golang.org/x/tools/internal/gcimporter\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\iexport.go:25:2: could not import golang.org/x/tools/internal/typeparams (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:17:2: could not import golang.org/x/tools/internal/pkgbits (EOF)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:103:4: r.Bool undefined (type *reader has no field or method Bool)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:105:19: r.Len undefined (type *reader has no field or method Len)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:108:5: r.Sync undefined (type *reader has no field or method Sync)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:109:13: r.Bool undefined (type *reader has no field or method Bool)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:110:16: r.Reloc undefined (type *reader has no field or method Reloc)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:111:12: r.Len undefined (type *reader has no field or method Len)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:114:4: r.Sync undefined (type *reader has no field or method Sync)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:156:15: pr.NewDecoder undefined (type *pkgReader has no field or method NewDecoder)\n..\\..\\..\\..\\go\\pkg\\mod\\golang.org\\x\\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\\internal\\gcimporter\\ureader_yes.go:156:15: too many errors\n"
}

1 tools failed to install.

gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: Command failed: C:\Program Files\Go\bin\go.exe install -v golang.org/x/tools/gopls@latest
golang.org/x/exp/slices
golang.org/x/vuln/osv
github.com/google/go-cmp/cmp/internal/diff
golang.org/x/tools/internal/event/keys
golang.org/x/mod/module
golang.org/x/tools/gopls/internal/span
golang.org/x/tools/go/analysis/passes/buildtag
golang.org/x/tools/go/analysis/passes/cgocall
golang.org/x/tools/go/analysis/passes/asmdecl
# github.com/google/go-cmp/cmp/internal/diff
..\..\..\..\go\pkg\mod\github.com\google\go-cmp@v0.5.9\cmp\internal\diff\diff.go:19:2: could not import github.com/google/go-cmp/cmp/internal/flags (EOF)
# golang.org/x/vuln/osv
..\..\..\..\go\pkg\mod\golang.org\x\vuln@v0.0.0-20221109205719-3af8368ee4fe\osv\json.go:19:7: could not import golang.org/x/vuln/internal/semver (EOF)
golang.org/x/tools/go/internal/cgo
golang.org/x/tools/go/ast/inspector
# golang.org/x/exp/slices
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\slices.go:15:8: could not import golang.org/x/exp/constraints (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\slices.go:68:8: invalid operation: v1 < v2 (type parameter E is not comparable with <)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\slices.go:70:8: invalid operation: v1 > v2 (type parameter E is not comparable with >)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\sort.go:42:6: invalid operation: x[i] < x[i - 1] (type parameter E is not comparable with <)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\sort.go:68:50: invalid operation: x[i] >= target (type parameter E is not comparable with >=)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\sort.go:69:22: invalid operation: x[pos] != target (incomparable types in type set)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\zsortordered.go:14:25: invalid operation: data[j] < data[j - 1] (type parameter E is not comparable with <)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\zsortordered.go:29:23: invalid operation: data[first + child] < data[first + child + 1] (type parameter E is not comparable with <)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\zsortordered.go:32:8: invalid operation: data[first + root] < data[first + child] (type parameter E is not comparable with <)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\zsortordered.go:110:17: invalid operation: data[a - 1] < data[pivot] (type parameter E is not comparable with <)
..\..\..\..\go\pkg\mod\golang.org\x\exp@v0.0.0-20221031165847-c99f073a8326\slices\zsortordered.go:110:17: too many errors
golang.org/x/tools/go/ast/astutil
golang.org/x/tools/go/analysis/passes/tests
golang.org/x/tools/internal/gcimporter
# golang.org/x/tools/internal/event/keys
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\event\keys\keys.go:13:2: could not import golang.org/x/tools/internal/event/label (EOF)
golang.org/x/vuln/vulncheck/internal/gosym
# golang.org/x/mod/module
..\..\..\..\go\pkg\mod\golang.org\x\mod@v0.7.0\module\pseudo.go:43:2: could not import golang.org/x/mod/internal/lazyregexp (EOF)
golang.org/x/tools/gopls/internal/lsp/analysis/embeddirective
debug/buildinfo
# golang.org/x/tools/gopls/internal/span
..\..\..\..\go\pkg\mod\golang.org\x\tools\gopls@v0.11.0\internal\span\token.go:11:2: could not import golang.org/x/tools/internal/bug (EOF)
honnef.co/go/tools/analysis/lint
# golang.org/x/tools/go/analysis/passes/buildtag
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\buildtag\buildtag.go:19:2: could not import golang.org/x/tools/go/analysis (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\buildtag\buildtag.go:20:2: could not import golang.org/x/tools/go/analysis/passes/internal/analysisutil (EOF)
honnef.co/go/tools/analysis/facts/generated
# golang.org/x/tools/go/internal/cgo
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\internal\cgo\cgo.go:67:7: could not import golang.org/x/sys/execabs (EOF)
honnef.co/go/tools/analysis/facts/tokenfile
# golang.org/x/tools/go/analysis/passes/cgocall
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\cgocall\cgocall.go:20:2: could not import golang.org/x/tools/go/analysis (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\cgocall\cgocall.go:21:2: could not import golang.org/x/tools/go/analysis/passes/internal/analysisutil (EOF)
# golang.org/x/tools/go/ast/inspector
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\ast\inspector\typeof.go:16:2: could not import golang.org/x/tools/internal/typeparams (EOF)
# golang.org/x/tools/go/analysis/passes/asmdecl
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\asmdecl\asmdecl.go:21:2: could not import golang.org/x/tools/go/analysis (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\asmdecl\asmdecl.go:22:2: could not import golang.org/x/tools/go/analysis/passes/internal/analysisutil (EOF)
honnef.co/go/tools/analysis/facts/deprecated
honnef.co/go/tools/analysis/edit
# golang.org/x/tools/gopls/internal/lsp/analysis/embeddirective
..\..\..\..\go\pkg\mod\golang.org\x\tools\gopls@v0.11.0\internal\lsp\analysis\embeddirective\embeddirective.go:12:2: could not import golang.org/x/tools/go/analysis (EOF)
honnef.co/go/tools/config
# golang.org/x/tools/go/analysis/passes/tests
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\tests\tests.go:19:2: could not import golang.org/x/tools/go/analysis (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\tests\tests.go:20:2: could not import golang.org/x/tools/internal/analysisinternal (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\analysis\passes\tests\tests.go:21:2: could not import golang.org/x/tools/internal/typeparams (EOF)
# golang.org/x/tools/go/ast/astutil
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\go\ast\astutil\enclosing.go:15:2: could not import golang.org/x/tools/internal/typeparams (EOF)
golang.org/x/tools/internal/memoize
# golang.org/x/vuln/vulncheck/internal/gosym
..\..\..\..\go\pkg\mod\golang.org\x\vuln@v0.0.0-20221109205719-3af8368ee4fe\vulncheck\internal\gosym\sym.go:11:2: could not import golang.org/x/vuln/internal/semver (EOF)
golang.org/x/tools/gopls/internal/lsp/browser
# honnef.co/go/tools/analysis/facts/generated
..\..\..\..\go\pkg\mod\honnef.co\go\tools@v0.3.3\analysis\facts\generated\generated.go:11:2: could not import golang.org/x/tools/go/analysis (EOF)
# debug/buildinfo
C:\Program Files\Go\src\debug\buildinfo\buildinfo.go:18:2: could not import debug/plan9obj (EOF)
# honnef.co/go/tools/analysis/lint
..\..\..\..\go\pkg\mod\honnef.co\go\tools@v0.3.3\analysis\lint\lint.go:14:2: could not import golang.org/x/tools/go/analysis (EOF)
# honnef.co/go/tools/analysis/facts/tokenfile
..\..\..\..\go\pkg\mod\honnef.co\go\tools@v0.3.3\analysis\facts\tokenfile\token.go:8:2: could not import golang.org/x/tools/go/analysis (EOF)
# honnef.co/go/tools/analysis/edit
..\..\..\..\go\pkg\mod\honnef.co\go\tools@v0.3.3\analysis\edit\edit.go:10:2: could not import golang.org/x/tools/go/analysis (EOF)
# honnef.co/go/tools/config
..\..\..\..\go\pkg\mod\honnef.co\go\tools@v0.3.3\config\config.go:14:2: could not import golang.org/x/tools/go/analysis (EOF)
# golang.org/x/tools/internal/memoize
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\memoize\memoize.go:29:2: could not import golang.org/x/tools/internal/xcontext (EOF)
# honnef.co/go/tools/analysis/facts/deprecated
..\..\..\..\go\pkg\mod\honnef.co\go\tools@v0.3.3\analysis\facts\deprecated\deprecated.go:10:2: could not import golang.org/x/tools/go/analysis (EOF)
# golang.org/x/tools/gopls/internal/lsp/browser
..\..\..\..\go\pkg\mod\golang.org\x\tools\gopls@v0.11.0\internal\lsp\browser\browser.go:9:7: could not import golang.org/x/sys/execabs (EOF)
# golang.org/x/tools/internal/gcimporter
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\iexport.go:25:2: could not import golang.org/x/tools/internal/typeparams (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:17:2: could not import golang.org/x/tools/internal/pkgbits (EOF)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:103:4: r.Bool undefined (type *reader has no field or method Bool)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:105:19: r.Len undefined (type *reader has no field or method Len)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:108:5: r.Sync undefined (type *reader has no field or method Sync)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:109:13: r.Bool undefined (type *reader has no field or method Bool)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:110:16: r.Reloc undefined (type *reader has no field or method Reloc)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:111:12: r.Len undefined (type *reader has no field or method Len)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:114:4: r.Sync undefined (type *reader has no field or method Sync)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:156:15: pr.NewDecoder undefined (type *pkgReader has no field or method NewDecoder)
..\..\..\..\go\pkg\mod\golang.org\x\tools@v0.3.1-0.20221213193459-ca17b2c27ca8\internal\gcimporter\ureader_yes.go:156:15: too many errors

下面是我的env设置:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\DNS\AppData\Local\go-build
set GOENV=C:\Users\DNS\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\DNS\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\DNS\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.4
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\DNS\AppData\Local\Temp\go-build1996119951=/tmp/go-build -gno-record-gcc-switches

我真的不明白是什么问题,希望你能帮助我。
我尝试更改一些环境设置,在其他目录中重新安装Go,清除modcache并设置GO111MODULE=on

mnemlml8

mnemlml81#

要执行此操作,请将cd发送到$GOPATH/src/golang.org/x/tools/,然后再次运行该命令。
如果这对你不起作用,那么你也可以尝试单独安装go,使用:

go install -v golang.org/x/tools/gopls@latest

如果你得到一个错误,说它不包含包golang,请在这里尝试:

go clean -modcache
go install -v golang.org/x/tools/gopls@latest

请让我知道如果你需要更多的帮助。

相关问题