Resolve: "go:linkname must refer to declared function or variable" in Go(lang)

Nov 27, 2022 · 1 min read · Post a comment

While compiling and building a dockerized Go(lang) stack running on macOS, I’ve received the following error line(s): ../../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable, which ends up with too many errors. Apparently this has to do something with the sys Go package that handles low-level operations with the OS.


  • Go(lang)


Step 1. Update the sys package.

go get -u golang.org/x/sys

Now, the go.mod file contains the following line:

golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 // indirect

Worth mentioning that the issue I was facing was when running Go version 1.18.


Not so much of a great practice but, updating packages of any general programming language is my first thing on the list when solving issues though. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.