go - 将外部包添加到 Hyperledger fabric -go smartcontract

标签 go stripe-payments hyperledger-fabric blockchain

我正在尝试向我的 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 包设置有疑问,请继续:

  1. 在项目根目录中使用空的有效 json 文件 (vendor.json) 创建文件夹 vendor
  2. 从根目录运行命令govendor add +external
  3. 您还可以使用更新命令更新所有依赖项。

关于go - 将外部包添加到 Hyperledger fabric -go smartcontract,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51240379/

相关文章:

go - 在 Go 中深度复制图结构

go - 如何优雅地从 `syscall.Syscall()`的使用迁移?

ruby - 如何在 Go 中进行适当的 Git 兼容的 hex sha 打包/压缩

ssl - super 账本结构 : How can a user be expected to have ca certificates of other organizations when trying to invoke chaincode?

hyperledger-fabric - 由于缺少 escc,Fabric v1.2.0 的链码实例化失败

go - 尝试构建 transfer.sh 时出错

javascript - 带 Stripe 的柏树 : elements height not loaded

vbscript - Stripe 与经典 ASP 集成

flutter - 在 Flutter 中集成 Stripe 支付

hyperledger-fabric - 如何访问 hyperledger composer 中的底层 Fabric 代码?