1. Online
Online, platform specific documentation can be accessed on the official Go home page, by appending the GOOS
and GOARCH
query parameters, similar to the environment variables.
For example, to access the syscall
package documentation for Windows 64-bit platform, visit:
https://golang.org/pkg/syscall/?GOOS=windows&GOACH=amd64
To quickly verify that it works, search for the type DLL
phrase (or simply DLL
), as those don't appear on linux's syscall package.
2. Offline
The go tool has default target platform and architecture which can be overridden with the GOOS
and GOARCH
environment variables. So by default go doc syscall
will show package documentation for the default platform and architecture.
To get doc for other platforms and / or architectures, all we need to do is change those environment variables.
On unix systems (e.g. linux, OS-X), we can simply prepend the go doc
command with the new platform / architecture we're interested in, e.g. package doc of syscall
for Windows (executed on Linux):
GOOS=windows go doc syscall
And that's all it takes. To quickly check if it works, print the DLL
type and its methods:
GOOS=windows go doc syscall DLL
Example output:
type DLL struct {
Name string
Handle Handle
}
A DLL implements access to a single DLL.
func MustLoadDLL(name string) *DLL
func (d *DLL) FindProc(name string) (proc *Proc, err error)
func (d *DLL) MustFindProc(name string) *Proc
func (d *DLL) Release() (err error)
This is documented in the syscall
package:
The details vary depending on the underlying system, and by default, godoc will display the syscall documentation for the current system. If you want godoc to display syscall documentation for another system, set $GOOS and $GOARCH to the desired system. For example, if you want to view documentation for freebsd/arm on linux/amd64, set $GOOS to freebsd and $GOARCH to arm.