I upgraded to Go 1.18 on Mac 12+.
'go build' fails with errors like:
# golang.org/x/sys/unix
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/syscall_darwin.1_13.go:25:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.1_13.go:27:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.1_13.go:40:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:28:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:43:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:59:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:75:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:90:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:105:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:121:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:121:3:
too many errors
Compilation finished with exit code 2
This was caused by an old version of golang.org/x/sys (mentioned in this issue). Fix is to update with:
go get -u golang.org/x/sys
As documentation mentioned,
The easiest way : run get -u golang.org/x/sys.
Manual : git clone the repository to $GOPATH/src/golang.org/x/sys.
I have faced same error and I fixed doing the following:
First I ran:
go get -u golang.org/x/sys
To update the x/sys library.
Then it printed some important information:
go: downloading golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e
go: upgraded golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd => v0.0.0-20220704084225-05e143d24a9e
With that in hands, I went to go.mod and I have placed the following line (before the go 1.14 line):
replace golang.org/x/sys => golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e
And finally I ran:
go mod vendor
Then it updated all the libraries:
go: downloading github.com/hashicorp/go-cleanhttp v0.5.1
go: downloading github.com/hashicorp/go-rootcerts v1.0.0
go: downloading github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
go: downloading github.com/mitchellh/cli v1.0.0
[...]
go: downloading github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
go: downloading github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
go: downloading github.com/Azure/go-autorest/autorest/to v0.4.0
Then it was fine
❯ go install .
❯ terraform --version
Terraform v0.13.5
EDIT:
Here I am using modules, if its not your case set GO111MODULE=off.
If go get -u golang.org/x/sys doesn't work, make sure to remove such line in your go.mod:
replace golang.org/x/sys => golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6
Try this I hope it will solve your problem as mine:
sudo go get golang.org/x/sys#latest
Related
I want to install this tool from github : https://github.com/ethicalhackingplayground/ssrf-tool
I am using the cmd : go install github.com/ethicalhackingplayground/ssrf-tool#latest
Output :
go: finding module for package github.com/projectdiscovery/gologger
go: finding module for package github.com/briandowns/spinner
go: finding module for package github.com/logrusorgru/aurora
go: found github.com/briandowns/spinner in github.com/briandowns/spinner v1.18.1
go: found github.com/logrusorgru/aurora in github.com/logrusorgru/aurora v2.0.3+incompatible
go: found github.com/projectdiscovery/gologger in github.com/projectdiscovery/gologger v1.1.4
# github.com/ethicalhackingplayground/ssrf-tool
..\..\..\go\pkg\mod\github.com\ethicalhackingplayground\ssrf-tool#v0.0.0-20200901082948-7f3cffc3c7bb\ssrftool.go:34:2: undefined: gologger.Printf
..\..\..\go\pkg\mod\github.com\ethicalhackingplayground\ssrf-tool#v0.0.0-20200901082948-7f3cffc3c7bb\ssrftool.go:35:2: undefined: gologger.Infof
..\..\..\go\pkg\mod\github.com\ethicalhackingplayground\ssrf-tool#v0.0.0-20200901082948-7f3cffc3c7bb\ssrftool.go:36:2: undefined: gologger.Infof
I am super new to golang, go installation is fine in my system because other tools from github are working fine.
If some changes are required in the code of this tool, please suggest so.
This sources created without go module support and an old version of gologger, here is a workaround:
Clone repository git clone git#github.com:ethicalhackingplayground/ssrf-tool.git
cd ssrf-tool create go.mod file with content:
module github.com/ethicalhackingplayground/ssrf-tool
go 1.17
require (
github.com/briandowns/spinner v1.18.1
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/projectdiscovery/gologger v1.0.1
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 // indirect
)
download deps go mod download
Build executable go build .
./ssrf-tool --help
Profit.
Here is the repo with the problem fixed.
go install github.com/R0X4R/ssrf-tool#latest
or
git clone https://github.com/R0X4R/ssrf-tool.git
cd ssrf-tool
go build ssrftool.go && mv ssrftool /usr/bin/
I upgraded to Go 1.18 on Mac 12+.
'go build' fails with errors like:
# golang.org/x/sys/unix
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/syscall_darwin.1_13.go:25:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.1_13.go:27:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.1_13.go:40:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:28:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:43:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:59:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:75:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:90:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:105:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:121:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/sys#v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:121:3:
too many errors
Compilation finished with exit code 2
This was caused by an old version of golang.org/x/sys (mentioned in this issue). Fix is to update with:
go get -u golang.org/x/sys
As documentation mentioned,
The easiest way : run get -u golang.org/x/sys.
Manual : git clone the repository to $GOPATH/src/golang.org/x/sys.
I have faced same error and I fixed doing the following:
First I ran:
go get -u golang.org/x/sys
To update the x/sys library.
Then it printed some important information:
go: downloading golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e
go: upgraded golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd => v0.0.0-20220704084225-05e143d24a9e
With that in hands, I went to go.mod and I have placed the following line (before the go 1.14 line):
replace golang.org/x/sys => golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e
And finally I ran:
go mod vendor
Then it updated all the libraries:
go: downloading github.com/hashicorp/go-cleanhttp v0.5.1
go: downloading github.com/hashicorp/go-rootcerts v1.0.0
go: downloading github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
go: downloading github.com/mitchellh/cli v1.0.0
[...]
go: downloading github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
go: downloading github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
go: downloading github.com/Azure/go-autorest/autorest/to v0.4.0
Then it was fine
❯ go install .
❯ terraform --version
Terraform v0.13.5
EDIT:
Here I am using modules, if its not your case set GO111MODULE=off.
If go get -u golang.org/x/sys doesn't work, make sure to remove such line in your go.mod:
replace golang.org/x/sys => golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6
Try this I hope it will solve your problem as mine:
sudo go get golang.org/x/sys#latest
I have a package that uses some local packages
module mycompany.com/clientname/server
go 1.14
require (
github.com/lib/pq v1.7.0
github.com/99designs/gqlgen v0.11.3
github.com/vektah/gqlparser/v2 v2.0.1
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
mycompany.com/clientname/models v0.0.0-00010101000000-000000000000
mycompany.com/common/utils v0.0.0-00010101000000-000000000000
)
replace mycompany.com/common/utils => ../../common/utils
replace mycompany.com/clientname/models => ../models
the mycompany.com domain doesn't serve the package, it is just a fictional path (and I use it in my gopath ~/go/src/mycompany.com/...)
the problem is that when I run go get -u all, I want the 'valid' packages to be updated (like the github.com/lib/pq or github.com/99designs/gqlgen), but to leave the local (fictional) packages as they are.
but go get -u all just prints out the new versions, then prints the errors on the local packages and then doesn't change go.mod.
go: google.golang.org/grpc upgrade => v1.30.0
go: go.opencensus.io upgrade => v0.22.4
go: github.com/mattn/go-runewidth upgrade => v0.0.9
go: github.com/gogs/chardet upgrade => v0.0.0-20191104214054-4b6791f73a28
go: golang.org/x/text upgrade => v0.3.3
go: github.com/mitchellh/mapstructure upgrade => v1.3.2
go get all: unrecognized import path "mycompany.com/clientname/models": reading https://mycompany.com/clientname/models?go-get=1: 404 Not Found
go get all: unrecognized import path "mycompany.com/common/utils": reading https://mycompany.com/common/utils?go-get=1: 404 Not Found
The error from go get -u was a bug in the go command, fixed in the upcoming Go 1.16 release. See https://golang.org/issue/32567 for detail.
(That said, ideally you should be hosting the modules in version control and using GOPRIVATE=mycompany.com instead of slotting things in locally via replace directives.)
Following this example of using go-micro. When I do a go mod init github.com/username/blahblah followed by a go get -u I get this in my go.mod file:
require (
github.com/coreos/etcd v3.3.21+incompatible // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/protobuf v1.4.2
github.com/imdario/mergo v0.3.9 // indirect
github.com/micro/go-micro/v2 v2.7.0
github.com/miekg/dns v1.1.29 // indirect
github.com/nats-io/nats.go v1.10.0 // indirect
go.uber.org/zap v1.15.0 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 // indirect
golang.org/x/tools v0.0.0-20200520220537-cf2d1e09c845 // indirect
google.golang.org/genproto v0.0.0-20200519141106-08726f379972 // indirect
google.golang.org/grpc v1.29.1 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
)
It fails with this message:
go: finding github.com/jbenet/go-context latest
go: finding go.uber.org/tools latest
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
../../../../../go3p/pkg/mod/github.com/coreos/etcd#v3.3.21+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
../../../../../go3p/pkg/mod/github.com/coreos/etcd#v3.3.21+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption
# github.com/coreos/etcd/clientv3/balancer/picker
../../../../../go3p/pkg/mod/github.com/coreos/etcd#v3.3.21+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
../../../../../go3p/pkg/mod/github.com/coreos/etcd#v3.3.21+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
Attempting to build with go build main.go fails with the same message.
This looks like .jar hell from Java. The culprit is go get. Is there a way to make go get resolve this problem?
Its a bug with version inconsistency between go-micro and grpc. About a week ago I tried to follow the tutorial which you mention and got same error. If you want to fix the error above please follow the interactions below the link:
https://github.com/etcd-io/etcd/issues/11563.
In additionally I recommend you just build grpc service without go-micro, due to version inconsistency.
I have a rest api I built in Go with gin that has been working for months now on my local machine running 1.12.1. I decided it was going to a docker deploy so I started building with 1.12.6 when I started see errors during module retrieval. I went back to my local machine, ran running 1.12.1 and ran go clean -modcache, now the error is there as well. I've tried regenerating multiple times even editing the go.sum file to different versions of gofight but I'm lost and run out of ideas.
The output w/error:
go: github.com/appleboy/gofight#v2.0.0+incompatible: go.mod has post-v2 module path "github.com/appleboy/gofight/v2" at revision v2.0.0
go: error loading module requirements
go.mod
module go-hybrid-alert
go 1.12
require (
cloud.google.com/go v0.37.0
firebase.google.com/go v3.6.0+incompatible
github.com/Luzifer/go-openssl v2.0.0+incompatible
github.com/PuerkitoBio/goquery v1.5.0
github.com/antchfx/htmlquery v1.0.0 // indirect
github.com/antchfx/xmlquery v1.0.0 // indirect
github.com/antchfx/xpath v0.0.0-20190129040759-c8489ed3251e // indirect
github.com/appleboy/gin-jwt v0.0.0-20190216100112-ca1084e5d5a2
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 // indirect
github.com/gin-gonic/gin v1.3.0
github.com/go-redis/redis v6.15.2+incompatible
github.com/gobwas/glob v0.2.3 // indirect
github.com/gocolly/colly v1.2.0
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/kisielk/godepgraph v0.0.0-20181003180210-9a9a3d47fba3 // indirect
github.com/levigross/grequests v0.0.0-20190130132859-37c80f76a0da // indirect
github.com/mattn/go-isatty v0.0.7 // indirect
github.com/mitchellh/mapstructure v1.1.2
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
github.com/temoto/robotstxt v0.0.0-20180810133444-97ee4a9ee6ea // indirect
github.com/ugorji/go/codec v0.0.0-20190316083543-95c34d148dff // indirect
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a
golang.org/x/net v0.0.0-20190313220215-9f648a60d977
google.golang.org/api v0.2.0
gopkg.in/dgrijalva/jwt-go.v3 v3.2.0 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
)
go.sum (the line for the module in question, posting the whole thing exceeds SO post length)
github.com/appleboy/gofight v2.0.0+incompatible/go.mod h1:H/tvof1oZHnZdlBd+AeODZGkk1C+D2na0NXr0iXuZHA=
I've also tried adjusting the go 1.12 statement in go.mod for the specific subversions I'm attempting to build with but that had no effect.
What does this error mean? How can I fix it?
A number of packages were outdated, the main fix was to run the new install command for gin-jwt, go get github.com/appleboy/gin-jwt/v2
Ultimately though I just nuked my go.mod and go.sum and did a fresh sync in Goland IDE. Everything is working on 1.12+