Can't run golang mobile package given examples - go

I was trying to test golang mobile package given examples(https://godoc.org/golang.org/x/mobile/example), but unfortunatly i get some errors:
C:\Users\D\Documents\gocode\src\golang.org\x\mobile\example\flappy>go run main.go
# golang.org/x/mobile/gl
..\..\gl\gl.go:1683: undefined: context3
..\..\gl\gl.go:1695: undefined: context3
..\..\gl\gl.go:1707: undefined: context3
..\..\gl\gl.go:1719: undefined: context3
..\..\gl\gl.go:1731: undefined: context3
..\..\gl\gl.go:1743: undefined: context3
..\..\gl\gl.go:1755: undefined: context3
..\..\gl\gl.go:1773: undefined: context3
..\..\gl\gl.go:1783: undefined: context3
..\..\gl\gl.go:1794: undefined: context3
..\..\gl\gl.go:1794: too many errors
For mobile package install, i wrote only go get golang.org/x/mobile command, i am using go1.6.2 windows/amd64 go version.

If you want to generate apk for testing, you should run command below:
gomobile build -target=android golang.org/x/mobile/example/flappy
more info can be found here

Related

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?

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

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

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