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

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.

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

What is the message when it is building on Golang?

When I build source on Golang, I saw the warning message, but I couldn't find answer about it.
$ go build --mod=mod -o main main.go
# command-line-arguments
ld: warning: -no_pie is deprecated when targeting new OS versions
specs
version : go version go1.18 darwin/amd64
os : Monterey 12.6
build command : go build --mod=mod -o [binary name] main.go
From GitHub: link
There are a few options:
- wait for the next Go 1.19.x and 1.18.x releases, probably early next month
- build Go from the master branch
- pass -buildmode=pie flag to go build and go test for a workaround
- use older version of the system linker
This seems to be a known issue. See Github for more information.
As a workaround you can pass the -buildmode=pie flag to your go build command.

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.

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

syscall variables undefined

When trying to build the following program on my Mac I get a build error: undefined: syscall.TCPInfo even though that variable is clearly documented http://golang.org/pkg/syscall/#TCPInfo
package main
import "syscall"
func main() {
_ = syscall.TCPInfo{}
}
Here is my go tool version.
$ go version
go version go1.3 darwin/amd64
I thought this might be an issue a lack of OS support so I tried it on http://play.golang.org, but it looks like many documented variables are just randomly missing from the syscall package: http://play.golang.org/p/w3Uk6NaZVy
Am I missing something?
The variable specified inside syscall are OS dependent.
you can add a suffix to the file to specify which os they should be built for:
// +build linux,386 darwin,!cgo
So you can use specific syscall flags for each OS.

Resources