如何在Fabric容器中安装第三方go库

时间:2017-06-02 02:37:47

标签: hyperledger hyperledger-fabric

我在我的链代码中使用了simplejson库,当我尝试部署我的链代码时,我得到了以下错误,我怎么能将这个库安装到结构容器中?我应该在Order中安装这个库还是我安装了我的chaincode的同伴?

当我进入容器(docker exec -it peer0 /bin/bash)并尝试运行go get github.com/bitly/go-simplejson时,它会告诉我go命令无法识别。

2017-06-02 02:31:34.982 UTC [logging] InitFromViper -> DEBU 001 Setting default logging level to DEBUG for command 'chaincode'
2017-06-02 02:31:34.996 UTC [msp] GetLocalMSP -> DEBU 002 Returning existing local MSP
2017-06-02 02:31:34.996 UTC [msp] GetDefaultSigningIdentity -> DEBU 003 Obtaining default signing identity
2017-06-02 02:31:35.007 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default escc
2017-06-02 02:31:35.007 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 005 Using default vscc
2017-06-02 02:31:35.008 UTC [msp] Sign -> DEBU 006 Sign: plaintext: 0A8E070A5A0803220A73736D6368616E...454D53500A04657363630A0476736363 
2017-06-02 02:31:35.009 UTC [msp] Sign -> DEBU 007 Sign: digest: 819428A66344065ADDA8D72882891E6D2EEB6BDFD4295F7AB1D2E340B0295E16 
Error: Error endorsing chaincode: rpc error: code = 2 desc = Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "chaincode/input/src/github.com/ssm/ssm.go:8:2: cannot find package "github.com/bitly/go-simplejson" in any of:
    /opt/go/src/github.com/bitly/go-simplejson (from $GOROOT)
    /chaincode/input/src/github.com/bitly/go-simplejson (from $GOPATH)
    /opt/gopath/src/github.com/bitly/go-simplejson

1 个答案:

答案 0 :(得分:1)

您可能需要在链代码中提供所有相关软件包(包括shim)。

有一个非常有用的教程https://www.youtube.com/watch?v=-mlUaJbFHcM