将外部程序包添加到Hyperledger Fabric -go smartcontract

时间:2018-07-09 07:44:09

标签: go stripe-payments hyperledger-fabric blockchain

我正在尝试向我的go smartcontract添加一个外部软件包(用于安装,我运行:去get github.com/stripe/stripe-go)。然后,在我的smartcontract(https://github.com/stripe/stripe-go)中,将文件条带“ github.com/stripe/stripe-go”导入并收取“ github.com/stripe/stripe-go/charge”。但是,当我尝试显示我的chaincode时,出现了错误:

错误:获取链码代码链码时出错:获取链码包字节码时出错:为github.com/stripe/stripe-go获取依赖项时出错::失败,错误为:“退出状态1” 无法加载程序包:程序包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)添加该软件包,但这也无法正常工作。

请大家在此帮助我。预先感谢。

1 个答案:

答案 0 :(得分:1)

我有类似的问题。 Govendor为我工作:

  

错误获取链码包字节:错误获取github.com/go-ozzo/ozzo-validation/is的依赖项

govendor add github.com/go-ozzo/ozzo-validation/is
govendor update +v
go build

结果很好:

  

Chaincode已安装在远程对等PEER2上

更新:

如果您对供应商软件包的设置有疑问,请按以下步骤操作:

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