小编max*_*eth的帖子

Go 模块在 VSCode 中导入问题(“无法在任何 [...] 中找到包 [...]”)

我遇到了可能是 Gopls 语言服务器问题:在 VSCode 中使用带有 Go 扩展的 Go 模块时,我的所有外部包导入语句都被标记为不正确。这正是我到目前为止所做的:

在我的 GOPATH/src/github.com/Kozie1337/projectname 中:

  • 跑步go mod init github.com/Kozie1337/projectname
  • 跑步go get -u github.com/gorilla/mux

go.main 里面:

package main

import (
    "log"
    "net/http"

    "github.com/gorilla/mux"  // This is being marked as wrong with the err. msg. down below
)

func main() {
  r := mux.NewRouter() // This actually works, even though the go linter says that mux isn't imported
  http.ListenAndServe(":9000", r)) // server starts too with mux routes
}

[...]
Run Code Online (Sandbox Code Playgroud)

将鼠标悬停在github.com/gorilla/mux导入语句上时,出现错误:

could …
Run Code Online (Sandbox Code Playgroud)

go go-modules

21
推荐指数
3
解决办法
3万
查看次数

标签 统计

go ×1

go-modules ×1