在Golang中安装”gorilla/mux”时遇到了问题。

huangapple go评论73阅读模式
英文:

trouble installing "gorilla/mux" in golang

问题

所以我通过在终端上输入以下代码来安装gorilla/mux,以便在我的API中使用它:

go get -u github.com/gorilla/mux

由于没有返回任何错误(也没有任何文本),我认为安装成功了。但是当我开始使用“mux.”something时,vscode显示名称“mux”未声明。有人有类似的经验或知道如何解决这个问题吗?提前感谢。

(使用go1.18.3)

英文:

So I installed gorilla/mux to use it for my API by typing this code on terminal

go get -u github.com/gorilla/mux

And since it didn't return any errors (nor any texts) I thought the install was successful. But When I started to use "mux. "something, vscode showed that the name "mux" is not declared. Does anyone had any similar experience or know how to solve the problem? Thanks in advance.

(Using go1.18.3)

答案1

得分: 1

你的项目中没有go.sum文件。

运行go mod tidy,问题就会解决。

英文:

Your project doesn't have go.sum file.

Run go mod tidy and you will be good to go.

huangapple
  • 本文由 发表于 2022年8月31日 20:03:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/73555646.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定