Search code examples
windowsgosystem-callsgolangci-lint

Where can I find the documentation for SyscallN, since syscall.Syscall6 has been deprecated as of Go 1.18?


When I run golangci-lint on my Go code after changing the go value in my go.mod from go 1.16 to go 1.20, I now get this linter warning:

windows.go:210:16: SA1019: syscall.Syscall6 has been deprecated since Go 1.18: Use SyscallN instead. (staticcheck)
        err, _, _ := syscall.Syscall6(fn, 5, addr, uintptr(unsafe.Pointer(&size)), 1, uintptr(family), uintptr(class), 0)

I wanted to compare the documentation for SyscallN to syscall.Syscall6 to see if there were any gotchas for moving from the deprecated function to the recommended replacement, but I cannot retrieve documentation for the function with go doc or find documentation for the function in the syscall package docs. The syscall package docs have a Syscall6 entry, but no SycallN entry. When I try to use go doc, I get this:

$ go doc syscall.SyscallN
doc: no symbol SyscallN in package syscall
exit status 1

Is SyscallN in a package other than syscall? Where can I find the documentation for SyscallN?

Note that this is for Windows-specific code guarded by a //go:build windows comment at the top of the windows.go file.


Solution

  • As pointed out by @SteffenUllrich, I had to change the Rendered for dropdown value from linux/amd64 like this:

    enter image description here

    to windows/amd64 like this:

    enter image description here

    The documentation for syscall.SyscallN is available here (note the query component in the URL): https://pkg.go.dev/syscall?GOOS=windows#SyscallN. Note that there is only a function signature in the documentation: enter image description here

    Snapshot of the page from when I wrote this answer: https://web.archive.org/web/20230208095250/https://pkg.go.dev/syscall?GOOS=windows#SyscallN

    Note

    The syscall docs page used to say the following in 2023:

    Deprecated: this package is locked down. Callers should use the corresponding package in the golang.org/x/sys repository instead. That is also where updates required by new systems or versions should be applied. See https://golang.org/s/go1.4-syscall for more information.

    The docs page now says (in January 4, 2025)

    NOTE: Most of the functions, types, and constants defined in this package are also available in the golang.org/x/sys package. That package has more system call support than this one, and most new code should prefer that package where possible. See https://golang.org/s/go1.4-syscall for more information.

    That said, it is not clear to me if golang.org/x/sys provides a way to make arbitrary syscalls, but it does have RawSyscall and RawSyscall6 for Unix platforms.