登录
首页 >  Golang >  Go问答

构建错误:Mac 上 Go 1.18 报错 "unix/syscall_darwin.1_13.go:25:3: //go:linkname 必须引用声明的函数或变量"

来源:stackoverflow

时间:2024-02-19 09:30:18 382浏览 收藏

最近发现不少小伙伴都对Golang很感兴趣,所以今天继续给大家介绍Golang相关的知识,本文《构建错误:Mac 上 Go 1.18 报错 "unix/syscall_darwin.1_13.go:25:3: //go:linkname 必须引用声明的函数或变量"》主要内容涉及到等等知识点,希望能帮到你!当然如果阅读本文时存在不同想法,可以在评论中表达,但是请勿使用过激的措辞~

问题内容

我在 mac 12+ 上升级到 go 1.18。

“go build”失败并出现如下错误:

# 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

正确答案


这是由 golang.org/x/sys 的旧版本引起的(在 this issue 中提到)。修复方法是更新:

go get -u golang.org/x/sys

到这里,我们也就讲完了《构建错误:Mac 上 Go 1.18 报错 "unix/syscall_darwin.1_13.go:25:3: //go:linkname 必须引用声明的函数或变量"》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>