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

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{}

Related

Trouble with go get install for mcumgr

I am trying to install MCUMgr on MACos. Here is a link for mcumgr: https://docs.zephyrproject.org/latest/services/device_mgmt/mcumgr.html
I install the Go Programming Language and enter this command:
go install github.com/apache/mynewt-mcumgr-cli/mcumgr#latest
Upon doing this I get the following error:
go/pkg/mod/golang.org/x/sys#v0.0.0-20200223170610-d5e6a3e2c0ae/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable
I then googled and found the following from stackoverflow: Go 1.18 build error on Mac: "unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable"
This gives me the following error:
go: golang.org/x/sys: unrecognized import path "golang.org/x": parse https://golang.org/x?go-get=1: no go-import meta tags ()
I am stuck right now on how to install MCUMgr for MACos and wondering if someone has previously had the same issues?
I used go 1.17 instead and used:
go get github.com/apache/mynewt-mcumgr-cli/mcumgr
Then into the bin folder where it is installed use sudo ./mcumgr to run.

"expected pseudo-register; found R13" error

I just run a go project with goland and got error as blow:
# github.com/choleraehyq/pid
../../../.go/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:28: expected pseudo-register; found R13
../../../.go/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:29: expected pseudo-register; found R14
asm: assembly of ../../../.go/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s failed
I'm confused about this error and I don't know what todo. I can't do some debug work by this error message and didn't get any useful informations from google. github.com/choleraehyq/pid is referred by under framework.
I just want to know what happened and how to fix it. Please help me, thank you every much.
My go version is 1.17.6, also with this problem.
I solve the problem by updating the package version:
go get -u github.com/choleraehyq/pid
go get: upgraded github.com/choleraehyq/pid v0.0.10 => v0.0.13
It happened when I update go version from 1.13 -> 1.19
and I solve the problem by updating the package version:
go get -u github.com/choleraehyq/pid
go: downloading github.com/choleraehyq/pid v0.0.15
go: upgraded github.com/choleraehyq/pid v0.0.13 => v0.0.15
I just want to know what happened and how to fix it.
Read the instructions.
Stack Overflow: Help: How to create a Minimal, Reproducible Example
Follow the instructions.
For example,
package goid
github.com/choleraehyq/pid#v0.0.10
Programatically retrieve the current goroutine's ID.
.
$ cat pid.go
package main
import (
"fmt"
goid "github.com/choleraehyq/pid"
)
func main() {
pid := goid.GetPid()
fmt.Println(pid)
}
$
.
$ cat go.mod
module example/pid
go 1.17
require github.com/choleraehyq/pid v0.0.10
$
.
$ go version
go version go1.17.5 linux/amd64
$
.
$ go build pid.go && ./pid
# github.com/choleraehyq/pid
../../gopath/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:28: expected pseudo-register; found R13
../../gopath/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:29: expected pseudo-register; found R14
asm: assembly of ../../gopath/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s failed
$
Upgrade to the latest version.
.
$ go get -u github.com/choleraehyq/pid
go: downloading github.com/choleraehyq/pid v0.0.13
go: upgraded github.com/choleraehyq/pid v0.0.10 => v0.0.13
$
.
$ cat go.mod
module example/pid
go 1.17
require github.com/choleraehyq/pid v0.0.13
$
.
$ go build pid.go && ./pid
1
$
Avoid using old, obsolete, and unsupported versions of software.
UPDATE:
Comment from OP:
Thanks. The original project is a big project and has deep dependencies. I find that I need to add github.com/choleraehyq/pid v0.0.13 // indirect to the project's go.mod. – sh1yu
It happened to me too. It maybe related to your golang's version;
I changed my golang's version from 1.17 to 1.14, which solved the problem.

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

Not able to install fabric-sdk-go and its dependencies

I am trying to download fabric-sdk-go library and all its dependency with the below command in a linux VM.
go get -u github.com/hyperledger/fabric-sdk-go/...
It is giving the below error.
# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations
../github.com/hyperledger/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)
# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util
../github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util/csp.go:47:8: cannot convert nil to type csr.KeyRequest
../github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util/csp.go:132:37: cannot use req.KeyRequest (type *csr.KeyRequest) as type csr.KeyRequest in argument to getBCCSPKeyOpts
Could this be because of go version mismatch or something? Here is the go version I am using the in linux VM.
go version go1.12.8 linux/amd64
If modules aren't turned on, go get will grab the incorrect version of some dependencies. As will most other dependency tools.
The first error # github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations is due to go-kit differences between v0.8.0 and v0.9.0.
The second error # github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util is due to a more recent version of cfssl than supported.
The sdk doesn't have an actual binary output, so we shouldn't be go get'ting it in any case.

Resources