Reputation: 1317
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/[email protected]/unix/syscall_darwin.1_13.go:25:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:27:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:40:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:43:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:59:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:75:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:90:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:105:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3:
//go:linkname must refer to declared function or variable
../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3:
too many errors
Compilation finished with exit code 2
Upvotes: 128
Views: 45639
Reputation: 754
Try this I hope it will solve your problem as mine:
sudo go get golang.org/x/sys@latest
Upvotes: 0
Reputation: 387
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
.
Upvotes: 4
Reputation: 18400
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
Upvotes: 348
Reputation: 22973
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
Upvotes: 2
Reputation: 558
As documentation mentioned,
get -u golang.org/x/sys
.$GOPATH/src/golang.org/x/sys
.Upvotes: 7