dongliao1949
2018-05-21 15:05 阅读 147

在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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    duanjiaren8188 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 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

    点赞 评论 复制链接分享

相关推荐