首页 文章

在golang中安装外部包

提问于
浏览
-4

我试图在我的golang代码中导入一个包 . 但它告诉我这个错误:

找不到包“github.com/mattbaird/jsonpatch”中的任何一个:/opt/go/src/github.com/mattbaird/jsonpatch(来自$ GOROOT)/chaincode/input/src/github.com/mattbaird/jsonpatch (来自$ GOPATH)/opt/gopath/src/github.com/mattbaird/jsonpatch“

有人可以帮我解决这个问题吗?

谢谢 .

2 回答

  • 0

    重新检查环境变量( $GOPATH$GOROOT ) .

    您遇到的问题是,您的代码正在 /opt/go/src/github.com//chaincode/input/src/github.com//opt/gopath/src/github.com/ 目录中搜索包 github.com/mattbaird/jsonpatch . 但是您已在 C:\Users\xyz\go\src\github.com 目录中安装了该软件包 .

  • 0

    确保正确设置了 $GOPATH 环境变量 .

    然后仔细检查软件包是否已安装,如果不是,则需要安装可以使用的软件包 .

    go get github.com/mattbaird/jsonpatch

相关问题