With Go 1.18, in my Machintosh 12+ I got an unexpected error; “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable”. A snippet of the error is given below:
# 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
I would like to share the steps that helped me to fix the error; “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable”.
Why “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable” error is seen?
The error, “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable”, is seen because this was an issue caused by the older version of golang that is golang.org/x/sys.
A detailed solution to fix the “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable” error is provided below:
How to fix “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable” error?
A simple solution to fix this would be to update your golang to the latest version as the issue is “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable” solved in the latest version.
To resolve the error “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable” you must follow the below steps.
You will need to update your golang to the latest version by using the following command:
go get -u golang.org/x/sys
This should fix the issue “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable”.
Conclusion
To fix the “unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable” error; update your golang to the latest version as the issue is solved in the latest version. You can use the following command to update your golang ” go get -u golang.org/x/sys “.