使用MacBook Pro, Big Sur操作系统,我按照hyperledger fabric文档进行操作,安装了所有需要的文件和工具。然而,当我到达最后一步时,代码生成了一个无法修复的goimports错误。错误如下:
johnny@JohnnyMBP fabric % make basic-checks integration-test-prereqs
All files are excluded from having license headers
Building github.com/client9/misspell/cmd/misspell -> misspell
Checking changed go files for spelling errors ...
spell checker passed
Checking for go:generate parent path references
Checking trailing spaces ...
DEP: Checking for dependency issues..
./scripts/check_deps.sh
Building golang.org/x/tools/cmd/goimports -> goimports
Building mvdan.cc/gofumpt -> gofumpt
Building honnef.co/go/tools/cmd/staticcheck -> staticcheck
LINT: Running code checks..
./scripts/golinter.sh
Checking with goimports
The following files contain goimports errors
bccsp/factory/nopkcs11.go
bccsp/factory/nopkcs11_test.go
bccsp/factory/pkcs11.go
bccsp/factory/pkcs11_test.go
bccsp/factory/pkcs11factory.go
bccsp/factory/pkcs11factory_test.go
bccsp/pkcs11/pkcs11_test.go
core/handlers/library/noplugin_test.go
core/handlers/library/plugin.go
core/handlers/library/plugin_stub.go
core/handlers/library/race_test.go
integration/ledger/ledger_generate_test.go
internal/fileutil/syncdir.go
internal/peer/node/signals.go
internal/peer/node/signals_windows.go
orderer/common/server/signals.go
orderer/common/server/signals_windows.go
The goimports command 'goimports -l -w' must be run for these files
make: *** [linter] Error 1
johnny@JohnnyMBP fabric %
这是我的go环境结果:
johnny@JohnnyMBP fabric % go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/johnny/Library/Caches/go-build"
GOENV="/Users/johnny/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/johnny/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/johnny/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17.2/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/johnny/github.com/webzest/fabric/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vs/8twtz6352nb26pnpyqfk11j80000gn/T/go-build698966046=/tmp/go-build -gno-record-gcc-switches -fno-common"
请提供一些指导,我可以遵循完成hyperledger fabric的开发环境。
更新:
我在所有。go文件上运行了goimports -l -w,并重新运行了一个基本检查。现在,我得到一个供应商错误:
johnny@JohnnyMBP fabric % make basic-checks
All files have SPDX-License-Identifier headers
Building github.com/client9/misspell/cmd/misspell -> misspell
Checking changed go files for spelling errors ...
spell checker passed
Checking for go:generate parent path references
Checking trailing spaces ...
DEP: Checking for dependency issues..
./scripts/check_deps.sh
Building golang.org/x/tools/cmd/goimports -> goimports
Building mvdan.cc/gofumpt -> gofumpt
Building honnef.co/go/tools/cmd/staticcheck -> staticcheck
LINT: Running code checks..
./scripts/golinter.sh
Checking with goimports
Checking with gofumpt
Checking for golang.org/x/net/context
Checking for github.com/gogo/protobuf
Checking with go vet
Checking with staticcheck
The following staticcheck issues were flagged
vendor/github.com/dustin/go-humanize/number.go:76:9: constant overflow (compile)
vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go:82:25: constant overflow (compile)
make: *** [linter] Error 1
johnny@JohnnyMBP fabric %
是否有人成功地使用最新版本的GO和最新版本的GIT为Fabric设置了开发环境?我需要帮助,好吗?
可以尝试两件事:
- 使用Go 1.16(这是目前用于构建/运行Fabric的版本)。
- 使用Go安装到/usr/local/Go与官方安装程序,而不是安装Homebrew。
如果这些文件中的导入确实有问题(除非在本地进行了修改,否则不应该有问题),请对列出的每个文件使用goimports -l -w
命令来纠正它们。
作为参考,我也使用Macbook Pro,运行MacOS Monterey,但以前使用Big Sur,make basic-checks
在最新的主上使用Go 1.16.9运行干净。分支代码。