Chaincode实例化与其他go包失败

时间:2018-01-10 20:29:14

标签: hyperledger-fabric hyperledger

需要有关链代码实例化的帮助,这取决于golang / protobuf和pkg / errors等其他go包。以下是我在对等日志中得到的错误

2018-01-10 19:59:42.040 UTC [endorser] simulateProposal -> ERRO 405 failed to invoke chaincode name:"lscc"  on transaction 380f014688cb8638b66cc9e9c8c85f1bf06ba062fbb979442483f7e9ae2139be, error: Error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "chaincode/input/src/Loyalty/loyalty.go:15:2: cannot find package "github.com/golang/protobuf/proto" in any of:
  /opt/go/src/github.com/golang/protobuf/proto (from $GOROOT)
  /chaincode/input/src/github.com/golang/protobuf/proto (from $GOPATH)
  /opt/gopath/src/github.com/golang/protobuf/proto
chaincode/input/src/Loyalty/loyalty.go:18:2: cannot find package "github.com/pkg/errors" in any of:
  /opt/go/src/github.com/pkg/errors (from $GOROOT)
  /chaincode/input/src/github.com/pkg/errors (from $GOPATH)
  /opt/gopath/src/github.com/pkg/errors

我已经将这些安装到对等的泊坞窗并且出现在这些/opt/gopath/src/github.com/golang/protobuf/proto个位置

1 个答案:

答案 0 :(得分:1)

为了编译链码,对等方使用fabric-ccenv基本映像启动新容器。结果,安装到对等文件夹/opt/gopath/src/github.com/golang/protobuf/proto在运行时不可用。

最好用链代码提供proto软件包,尝试在项目的根文件夹中运行以下命令:

govendor add github.com/golang/protobuf/proto

此命令应创建子文件夹vendor/github.com/golang/protobuf/proto,并用所有必需的文件填充子文件夹。 只需尝试再次安装您的链码,所需的依赖项将随您的源代码一起提供,并且在运行时可用。