【问题标题】:VSCode with WSL Remote + Golang gopls installation is failing with the error带有 WSL Remote + Golang gopls 的 VSCode 安装失败并出现错误
【发布时间】:2020-04-17 01:18:34
【问题描述】:

当 VSCode 尝试安装 golang.org/x/tools/gopls 时,它会抛出以下错误。

get "golang.org/x/tools": found meta tag get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools?go-get=1
go: finding golang.org/x/tools v0.0.0-20191108194844-46f05828f2fe
go: downloading golang.org/x/tools/gopls v0.2.0
golang.org/x/tools/internal/lsp/source
# golang.org/x/tools/internal/lsp/source
../../../pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/source/completion.go:697:21: file.LineStart undefined (type *token.File has no field or method LineStart)
../../../pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/source/format.go:246:27: fset.File(f.Pos()).LineStart undefined (type *token.File has no field or method LineStart)
../../../pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/source/format.go:271:13: tok.LineStart undefined (type *token.File has no field or method LineStart)

【问题讨论】:

    标签: go visual-studio-code windows-subsystem-for-linux


    【解决方案1】:

    在尝试使用 YouCompleteMe 为 VIM 构建完成时遇到同样的问题:

    # golang.org/x/tools/internal/lsp/source
    third_party/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/source/completion.go:697:21: file.LineStart undefined (type *token.File has no field or method LineStart)
    third_party/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/source/format.go:246:27: fset.File(f.Pos()).LineStart undefined (type *token.File has no field or method LineStart)
    third_party/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/source/format.go:271:13: tok.LineStart undefined (type *token.File has no field or method LineStart)
    

    解决方案:

    从 go 1.11.4 切换到 1.12beta1 似乎已经为我解决了这个问题!

    【讨论】:

    • 1.不要在 go.mod 退出的地方运行此命令 2. 尝试从这里 rm -r $GOPATH/pkg/mod/golang.org/x/tools/gopls@VERSIONHERE/ 删除旧版本,如果您不是从 go.mod 位置运行,请重试。
    猜你喜欢
    • 1970-01-01
    • 2017-08-28
    • 1970-01-01
    • 2021-07-31
    • 2020-10-02
    • 2016-11-08
    • 1970-01-01
    • 2014-06-01
    • 1970-01-01
    相关资源
    最近更新 更多