Unexplained errors when using "go get" - go

I'm using go 1.9 on OS X 10.12.6. I was attempting to "go get" github.com/maxbrunsfeld/counterfeiter, and was presented with the following cryptic errors:
% go get github.com/maxbrunsfeld/counterfeiter
# golang.org/x/sys/unix
code/go/src/golang.org/x/sys/unix/dirent.go:68:17: undefined: direntReclen
code/go/src/golang.org/x/sys/unix/dirent.go:74:14: undefined: direntIno
code/go/src/golang.org/x/sys/unix/dirent.go:81:24: constant -1000000000 overflows uint64
code/go/src/golang.org/x/sys/unix/dirent.go:81:41: undefined: Dirent
code/go/src/golang.org/x/sys/unix/dirent.go:82:17: undefined: direntNamlen
code/go/src/golang.org/x/sys/unix/flock.go:13:30: undefined: SYS_FCNTL
code/go/src/golang.org/x/sys/unix/flock.go:16:42: undefined: Flock_t
code/go/src/golang.org/x/sys/unix/flock.go:17:17: undefined: Syscall
I also attempted to go get with -u and -v, and while verbose mode provides some more information, none is really relevant to the errors seen here. Has anyone seen anything like this before?

Solved the same issue with just GOOS=linux GOARCH=amd64 go get ...

Related

underfined function error in go :jmpToFunctionValue

While running main.go getting this error in monkey file and function is given below.
bou.ke/monkey
../go/pkg/mod/bou.ke/monkey#v1.0.2/replace.go:24:14: undefined: jmpToFunctionValue
Anyone help me with that?
I also face this error while using mac M1.
could you check the goarch var in go env? if you got arm64, you need to change it to amd64 using this command
go env -w GOARCH=amd64
it works for me

I encountered an error while installing Fabric CA with the go get command

when executing
go get -u github.com/hyperledger/fabric-ca/cmd/
I get the following error:
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg#version' instead.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
# github.com/hyperledger/fabric-ca/internal/pkg/util
/opt/go/pkg/mod/github.com/hyperledger/fabric-ca#v1.5.2/internal/pkg/util/csp.go:117:12: undefined: bccsp.RSA2048KeyGenOpts
/opt/go/pkg/mod/github.com/hyperledger/fabric-ca#v1.5.2/internal/pkg/util/csp.go:119:12: undefined: bccsp.RSA3072KeyGenOpts
/opt/go/pkg/mod/github.com/hyperledger/fabric-ca#v1.5.2/internal/pkg/util/csp.go:121:12: undefined: bccsp.RSA4096KeyGenOpts
# github.com/hyperledger/fabric-ca/lib/server/operations
/opt/go/pkg/mod/github.com/hyperledger/fabric-ca#v1.5.2/lib/server/operations/system.go:173:23: not enough arguments in call to s.statsd.SendLoop
have (<-chan time.Time, string, string)
want (context.Context, <-chan time.Time, string, string)
go version
go version go1.17.2 linux/amd64
go 1.17.2 isn't a supported version for fabric-ca 1.5.2 check the release notes for the supported version here https://github.com/hyperledger/fabric-ca/releases/tag/v1.5.2
however there is also an issue with a dependency that has changed an api such that using the -u option on go get means that it will download and use an incompatible version. This applies only to the server so for the server
go get github.com/hyperledger/fabric-ca/cmd/fabric-ca-server
should work, but you can also do
go get github.com/hyperledger/fabric-ca/cmd/...
to include a client build as well
You can of course just get official builds from https://github.com/hyperledger/fabric-ca/releases/tag/v1.5.2

"go.etcd.io/etcd/clientv3/balancer/picker" - undefined: balancer.PickOptions

I'm getting the following error in golang
# go.etcd.io/etcd/clientv3/balancer/picker
/home/user/go/src/go.etcd.io/etcd/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
/home/user/go/src/go.etcd.io/etcd/clientv3/balancer/picker/roundrobin_balanced.go:55:54:
undefined: balancer.PickOptions
# go.etcd.io/etcd/clientv3/balancer/resolver/endpoint
/home/user/go/src/go.etcd.io/etcd/clientv3/balancer/resolver/endpoint/endpoint.go:114:78:
undefined: resolver.BuildOption
/home/user/go/src/go.etcd.io/etcd/clientv3/balancer/resolver/endpoint/endpoint.go:183:31:
undefined: resolver.ResolveNowOption
I have tried
go get -u google.golang.org/grpc
but still getting same issue. My version of grpc is v1.26.0
Any solutions?
Are you sure your version is v1.26.0?
Can you share your go.mod please?
go get -u google.golang.org/grpc
The above command is to retrieve latest version of grpc which is v1.27.1
Once you change the version in your go.mod from
google.golang.org/grpc v1.27.0
to
google.golang.org/grpc v1.26.0
you will need to run following command to lock the version:
go get google.golang.org/grpc#v1.26.0

How can I run test on Hyperledger Fabric code?

I'm sorry to interrupt you guys, but I wish to know how can I run the Hyperledger Fabric code originally.
I download all the Go, Docker, Docker composer, VSCode and those plugins for Go.
And when I using go test consensus_test.go in /orderer/solo.
It will give me these answer, so how can I run these code? Thank you.
$fabric#ubuntu:~/go/src/github.com/hyperledger/fabric/orderer/consensus/solo$ go test consensus_test.go
# command-line-arguments
./consensus_test.go:35:26: undefined: pkgLogID
./consensus_test.go:45:48: undefined: chain
./consensus_test.go:74:8: undefined: newChain
./consensus_test.go:95:11: undefined: New
./consensus_test.go:116:8: undefined: newChain
./consensus_test.go:134:8: undefined: newChain
./consensus_test.go:178:8: undefined: newChain
./consensus_test.go:220:8: undefined: newChain
./consensus_test.go:256:8: undefined: newChain
./consensus_test.go:293:8: undefined: newChain
./consensus_test.go:293:8: too many errors
FAIL command-line-arguments [build failed]
fabric#ubuntu:~/go/src/github.com/hyperledger/fabric/orderer/consensus/solo$
Solved, but I don't know what happened and why.
VScode will gives a "run file test||run package test" hint on the top, I click it and it running success.

Undefined: syscall.Kill on Windows

I'm using eaburns/Watch library on a windows machine, but when trying to get the package with go get github.com/eaburns/Watch I get the following errors:
main.go:159: undefined: syscall.Kill
main.go:169: undefined: syscall.Wait4
main.go:169: undefined: syscall.WNOHANG
Any reason why this happens only on windows computers? How to fix this?
The syscall package is dependent on the operating system. syscall.Kill is for Unix/Linux/Mac systems, not Windows.
Use godoc syscall to get information on the syscall package for your system. This is explained in the Overview section in the package documentation:
https://golang.org/pkg/syscall/

Resources