由于Fabric 1.1和1.0的包装问题,我的Hyperledger Fabirc无法与Go一起构建

时间:2019-10-12 18:22:25

标签: go hyperledger-fabric hyperledger

现在,我正在关注本教程https://github.com/chainHero/heroes-service

设置.goyamltoml脚本后, dep ensure,然后go build

我得到了错误

# github.com/chainHero/heroes-service/vendor/github.com/zmap/zlint/lints
vendor/github.com/zmap/zlint/lints/result.go:75:9: undefined: strings.ReplaceAll
# github.com/chainHero/heroes-service/vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util
vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util/csp.go:47:8: cannot convert nil to type csr.KeyRequest
vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util/csp.go:132:37: cannot use req.KeyRequest (type *csr.KeyRequest) as type csr.KeyRequest in argument to getBCCSPKeyOpts

我听说这是由于1.01.1的版本问题所致,后者是我的。我认为这会得到解决,因为在Gopkg.toml

# github.com/chainHero/heroes-service/vendor/github.com/zmap/zlint/lints
vendor/github.com/zmap/zlint/lints/result.go:75:9: undefined: strings.ReplaceAll
# github.com/chainHero/heroes-service/vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util
vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util/csp.go:47:8: cannot convert nil to type csr.KeyRequest
vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util/csp.go:132:37: cannot use req.KeyRequest (type *csr.KeyRequest) as type csr.KeyRequest in argument to getBCCSPKeyOpts

我仍然需要导入Go软件包吗?

更新:

我安装了Go 1.13.1,现在我go build

build github.com/chainHero/heroes-service: cannot load github.com/hyperledger/fabric-sdk-go/pkg/client/msp: open /home/luke/go/src/github.com/hyperledger/fabric-sdk-go/pkg/client/msp: no such file or directory

我猜想这与在这里使用Fabric 1.0有关...

1 个答案:

答案 0 :(得分:1)

由于您的错误,Fabric v1.1似乎使用了go标准库中的strings.ReplaceAll,而您安装的Go版本不支持它。

根据strings.ReplaceAll的文档,它是在go版本1.12中添加的,因此您应该使用go => 1.12的go版本