dongliao1949
2018-05-21 15:05
浏览 172

在Golang中安装外部软件包

I am trying to import a package in my golang code. But it is showing me this error:

cannot find package "github.com/mattbaird/jsonpatch" in any of: /opt/go/src/github.com/mattbaird/jsonpatch (from $GOROOT) /chaincode/input/src/github.com/mattbaird/jsonpatch (from $GOPATH) /opt/gopath/src/github.com/mattbaird/jsonpatch "

Can somebody help me fix this?

Thanks.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用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“ < / p>

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

谢谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanjiaren8188 2018-05-24 10:16
    已采纳

    Recheck your environment variables($GOPATH, $GOROOT).

    The problem you are facing is that, your code is searching for the package github.com/mattbaird/jsonpatch in /opt/go/src/github.com/, /chaincode/input/src/github.com/ and /opt/gopath/src/github.com/ directories. But you have installed the package in C:\Users\xyz\go\src\github.com directory.

    点赞 评论
  • douxun3496 2018-05-21 15:08

    Ensure your $GOPATH environment variable is set up correctly.

    Then double check the packages are installed, if not you need to install the package which you can do with.

    go get github.com/mattbaird/jsonpatch

    点赞 评论

相关推荐 更多相似问题