HyperLedger Fabric SDK Go显示无法将nil转换为csr.KeyRequest类型

Sum*_*ora 1 hyperledger-fabric hyperledger-fabric-sdk-go

一种基于go-lang的微服务代码需要与Fabric的链式代码连接,直到上次都运行良好,到目前为止没有问题。

但是现在在构建具有结构客户端代码与结构链代码连接的基于go的微服务时,它显示了以下问题。

../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:无法将nil转换为csr.KeyRequest类型 ../../vendor/github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util/csp.go:132:37:无法使用req.KeyRequest(类型* csr.KeyRequest)作为getBCCSPKeyOpts的参数中的csr.KeyRequest类型

也许是一个依赖性问题,我清理了完整的供应商目录,并完成了确保--update的操作,但是它显示了同样的问题,

更多信息 :

转到1.12版

在GoPkg.Toml

[[override]] name =“ github.com/hyperledger/fabric”分支=“ master”

[[override]] name =“ github.com/hyperledger/fabric-sdk-go”分支=“ master”

我尝试了fabric-sdk-go的各种组合和不同分支,尽管它之前工作得很好,但它仍然显示相同的内容。

小智 5

自1.0.0-alpha5版本发布以来,fabric-sdk-go所依赖的软件包似乎发生了许多变化。

当我现在运行go build并仅导入一个外部依赖项(github.com/hyperledger/fabric-sdk-go)时,我得到了以下go.mod文件,(我go mod用于包管理)

...

require (
    github.com/cloudflare/cfssl v0.0.0-20190726000631-633726f6bcb7 // indirect
    github.com/go-kit/kit v0.9.0 // indirect
    github.com/golang/mock v1.3.1 // indirect
    github.com/golang/protobuf v1.3.2 // indirect
    github.com/google/certificate-transparency-go v1.0.21 // indirect
    github.com/hyperledger/fabric-lib-go v1.0.0 // indirect
    github.com/hyperledger/fabric-sdk-go v1.0.0-alpha5
    github.com/pkg/errors v0.8.1 // indirect
    github.com/prometheus/client_golang v1.0.0 // indirect
    github.com/spf13/viper v1.4.0 // indirect
    github.com/zmap/zlint v0.0.0-20190730215301-9971d62266e7 // indirect
    golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
    google.golang.org/grpc v1.22.1 // indirect
)
Run Code Online (Sandbox Code Playgroud)

其中包含最新版本的软件包,并且似乎会引起一些构建问题,如下所示,包括您所拥有的。

# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations
../../Go/pkg/mod/github.com/hyperledger/fabric-sdk-go@v1.0.0-alpha5/internal/github.com/hyperledger/fabric/core/operations/system.go:185:43: undefined: "github.com/prometheus/client_golang/prometheus".Handler
../../Go/pkg/mod/github.com/hyperledger/fabric-sdk-go@v1.0.0-alpha5/internal/github.com/hyperledger/fabric/core/operations/system.go:227:23: not enough arguments in call to s.statsd.SendLoop
        have (<-chan time.Time, string, string)
        want (context.Context, <-chan time.Time, string, string)
# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util
../../Go/pkg/mod/github.com/hyperledger/fabric-sdk-go@v1.0.0-alpha5/internal/github.com/hyperledger/fabric-ca/util/csp.go:46:8: cannot convert nil to type csr.KeyRequest
../../Go/pkg/mod/github.com/hyperledger/fabric-sdk-go@v1.0.0-alpha5/internal/github.com/hyperledger/fabric-ca/util/csp.go:131:37: cannot use req.KeyRequest (type *csr.KeyRequest) as type csr.KeyRequest in argument to getBCCSPKeyOpts
Run Code Online (Sandbox Code Playgroud)

上次成功构建时,我手动编写了go.mod文件来包含特定版本的依赖项。

...
require (
    github.com/cloudflare/cfssl v0.0.0-20190409034051-768cd563887f // indirect
    github.com/go-kit/kit v0.8.0 // indirect
    github.com/go-logfmt/logfmt v0.4.0 // indirect
    github.com/golang/mock v1.3.0 // indirect
    github.com/google/certificate-transparency-go v1.0.21 // indirect
    github.com/hyperledger/fabric-lib-go v1.0.0 // indirect
    github.com/hyperledger/fabric-sdk-go v1.0.0-alpha5
    github.com/pkg/errors v0.8.1 // indirect
    github.com/prometheus/client_golang v0.9.2 // indirect
    github.com/spf13/viper v1.3.2 // indirect
    google.golang.org/grpc v1.20.1 // indirect
)

Run Code Online (Sandbox Code Playgroud)

而且效果很好。