我在Mac 12+上升级到了Go 1.18。
“go build”失败,错误如下:
# 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
5条答案
按热度按时间wgxvkvu91#
这是由旧版本的
golang.org/x/sys
(在this issue中提到)导致的。修复方法是更新为:8yparm6h2#
如文件所述,
1.最简单的方法:运行
get -u golang.org/x/sys
。1.手动:git克隆仓库到
$GOPATH/src/golang.org/x/sys
。qxgroojn3#
我遇到了同样的错误,我修复做以下:
我先跑:
更新
x/sys
库。然后它打印了一些重要的信息:
有了它,我转到
go.mod
,并放置了以下行(在go 1.14
行之前):最后我跑了:
然后它更新了所有的库:
那就没事了
编辑:这里我使用
modules
,如果不是你的情况设置GO111MODULE=off
。gmxoilav4#
如果
go get -u golang.org/x/sys
不起作用,请确保删除go.mod
中的以下行:ttcibm8c5#
试试这个,我希望它能解决你和我的问题: