我正在尝试向我的 go smartcontract 添加一个外部包(为了安装,我运行了:go get github.com/stripe/stripe-go)。然后我在我的智能合约(https://github.com/stripe/stripe-go)中导入了文件 stripe "github.com/stripe/stripe-go"和 charge "github.com/stripe/stripe-go/charge"。但是,当我尝试调出我的链代码时,出现错误:
错误:获取链代码时出错 无法加载包:包 github.com/stripe/stripe-go:在以下任何一个中找不到包“github.com/stripe/stripe-go”: /opt/go/src/github.com/stripe/stripe-go(来自 $GOROOT) /opt/gopath/src/github.com/stripe/stripe-go(来自 $GOPATH)
我尝试通过 govendor (http://hyperledger-fabric.readthedocs.io/en/release-1.0/Style-guides/go-style.html) 添加包,但这也不起作用。
请大家帮我解决这个问题。提前致谢。
最佳答案
我遇到了类似的问题。 Govendor 为我工作:
error getting chaincode package bytes: Error obtaining dependencies for github.com/go-ozzo/ozzo-validation/is
govendor add github.com/go-ozzo/ozzo-validation/is
govendor update +v
go build
结果很好:
Chaincode is installed on remote peer PEER2
更新:
如果您对 vendor 包设置有疑问,请继续:
- 在项目根目录中使用空的有效 json 文件 (vendor.json) 创建文件夹 vendor
- 从根目录运行命令
govendor add +external
- 您还可以使用更新命令更新所有依赖项。
关于go - 将外部包添加到 Hyperledger fabric -go smartcontract,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51240379/