运行 "go build" 命令时出现错误“调用 s.statsd.SendLoop 时参数不足”

Getting error " not enough arguments in call to s.statsd.SendLoop" when running "go build" command

我正在尝试 运行 为我的项目执行 go build 命令,但它退出并出现以下错误。

alpha@GHOST-RIDER:~/GoWorkspace/src/github.com/hyperledger/firstproject$ go build
# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations
../fabric-sdk-go/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)

如有任何帮助,我们将不胜感激。

在 hyperledger-fabric-go-sdk 群聊上找到了解决方案。

s.statsd.SendLoop 中添加 context.Background(),如下所示

s.statsd.SendLoop(context.Background(), s.sendTicker.C, network, address)

fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations/system.go 文件第 227 行。

根据 code fabric 使用此库的不同版本:github.com/go-kit/kit/metrics/statsd。如果您遵循 System 结构的 statsd 属性,您可以在导入时找到引用。

在这个库的 master 分支中,SendLoop 函数需要 4 属性,所以这是根本原因。因此,当您在本地环境中编译时,这会导致错误。

我遇到了同样的问题,并通过检查库的标签解决了这个问题,如下所示:

cd $GOPATH/src/github.com/go-kit/kit
git fetch --tags
git checkout v0.8.0