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

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

Related

Go module installation error "undefined: any" [duplicate]

This question already has an answer here:
Why do I get "undeclared name: any (requires version go1.18 or later)" when using any instead of interface{}? I am using Go 1.18
(1 answer)
Closed 2 months ago.
I got the following error. Could anybody try the same command? I want to know whether it is a bug in the package or it is related to the version of go that I use or my setup.
$ go get github.com/gonejack/webarchive-to-html
# github.com/alecthomas/kong
../../../go/src/github.com/alecthomas/kong/callbacks.go:105:65: undefined: any
../../../go/src/github.com/alecthomas/kong/callbacks.go:124:15: undefined: any
../../../go/src/github.com/alecthomas/kong/context.go:723:27: undefined: any
../../../go/src/github.com/alecthomas/kong/options.go:59:8: undefined: any
../../../go/src/github.com/alecthomas/kong/options.go:66:18: undefined: any
$ echo $?
2
$ go version
go version go1.16 darwin/amd64
Let's see go.mod file of the package you trying to get. The package is written down based on 1.18 version of golang. So you need at least 1.18 version.
module github.com/gonejack/webarchive-to-html
go 1.18
...
Built-in type any is introduced in go 1.18. any is a simple alias for interface{}.
// builtin.go
type any = interface{}

Unable to compile simple go program using foundationdb

Trying to cross compile on macos arm for linux. My sample project looks like this:
main.go:
package main
import(
"github.com/apple/foundationdb/bindings/go/src/fdb"
)
func main() {
fdb.APIVersion(630)
fdb.MustOpenDatabase("fdb.cluster")
}
go.mod
module fdbtest
go 1.19
require github.com/apple/foundationdb/bindings/go v0.0.0-20221026173525-97cc643cef69
require golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
go.sum
github.com/apple/foundationdb/bindings/go v0.0.0-20221026173525-97cc643cef69 h1:vG55CLKOUgyuD15KWMxqRgTPNs8qQfXPtWjYYN5Wai0=
github.com/apple/foundationdb/bindings/go v0.0.0-20221026173525-97cc643cef69/go.mod h1:w63jdZTFCtvdjsUj5yrdKgjxaAD5uXQX6hJ7EaiLFRs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
I've installed foundationdb go lang bindings via go get github.com/apple/foundationdb/bindings/go#6.3.25
but when I do env GOOS=linux GOARCH=amd64 go build I get the following errors:
env GOOS=linux GOARCH=amd64 go build
# github.com/apple/foundationdb/bindings/go/src/fdb
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go#v0.0.0-20221026173525-97cc643cef69/src/fdb/keyselector.go:39:10: undefined: KeyConvertible
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go#v0.0.0-20221026173525-97cc643cef69/src/fdb/snapshot.go:33:3: undefined: transaction
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go#v0.0.0-20221026173525-97cc643cef69/src/fdb/generated.go:45:9: undefined: NetworkOptions
<...>
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go#v0.0.0-20221026173525-97cc643cef69/src/fdb/generated.go:94:9: too many errors
So it seems that it cannot find any of the types from fdb. Yet the KeyConvertible and the NetworkOptions (and others) exist in ../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go#v0.0.0-20221026173525-97cc643cef69/src/fdb/fdb.go
My golang version: go version go1.19.3 darwin/arm64
Newer fdb go bindings (7.1.25, 7.1.0) seem to behave the same...
what am I missing here?

Go installs latest version of dependency even if specific version is mentioned in go.mod

I am installing golint package in my CI pipeline and I am using Go v1.16. Now because of golint, it installs sys v0.2.0 even if golint's go.mod file has specific versioned dependencies.
golint installs golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 (https://github.com/golang/lint/blob/master/go.mod)
gotools installs golang.org/x/net v0.0.0-20190620200207-3b0461eec859 (https://github.com/golang/tools/blob/2f3ba24bd6e75104fb11be4edf062de340ffd1ab/go.mod)
x/net installs golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a (https://github.com/golang/net/blob/3b0461eec859c4b73bb64fdc8285971fd33e3938/go.mod)
Which is not v0.2.0. But still sys having v0.2.0 is being installed and because of that other code/stages fails with error:
/go/pkg/mod/golang.org/x/sys#v0.2.0/unix/syscall.go:83:16: undefined: unsafe.Slice
/go/pkg/mod/golang.org/x/sys#v0.2.0/unix/syscall_linux.go:2255:9: undefined: unsafe.Slice
/go/pkg/mod/golang.org/x/sys#v0.2.0/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
/go/pkg/mod/golang.org/x/sys#v0.2.0/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
I have also checked release dates for sys here: https://github.com/golang/sys/tags and the above mentioned sys version is from past (from 2019) and it should work with Go v1.16.
What am I missing here?

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

Unexplained errors when using "go get"

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 ...

Resources