如何访问平台特定的软件包文档? [英] How to access platform specific package documentation?

查看:74
本文介绍了如何访问平台特定的软件包文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在官方网站上在线访问Go的包装文档:

We can access Go's package documentation online on the official website:

https://golang.org/pkg/

仅包含 linux 平台( GOOS ), amd64 架构( GOARCH ).

This only contains the package documentation available on the linux platform (GOOS), amd64 archicture (GOARCH).

或通过 go doc 命令脱机,例如 的打包文档syscall 程序包.

Or offline via the go doc command, e.g package doc of the syscall package.

go doc syscall

这显示了Go SDK平台的文档.

This shows documentation for the platform of the Go SDK.

根据我们所针对的平台,某些程序包具有不同的API,其中最著名的是 syscall 程序包.

Some packages have different API based on the platform we target, most famous is the syscall package.

我们如何在线和离线访问特定于平台的软件包文档?

How can we access platform specific package documentation online and offline?

推荐答案

1.在线

可以通过添加 GOOS GOARCH 查询参数(类似于环境变量),在官方的Go主页上访问特定于平台的在线文档.

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.

例如,要访问Windows 64位平台的 syscall 软件包文档,请访问:

For example, to access the syscall package documentation for Windows 64-bit platform, visit:

https://golang.org/pkg/syscall/?GOOS= windows& GOACH = amd64

要快速验证其是否有效,请搜索 type DLL 短语(或简称为 DLL ),因为那些没有出现在linux的syscall软件包中.

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.

go工具具有默认的目标平台和体系结构,可以用 GOOS GOARCH 环境变量覆盖.因此,默认情况下, go doc syscall 将显示默认平台和体系结构的软件包文档.

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.

在Unix系统(例如linux,OS-X)上,我们可以简单地在 go doc 命令前添加我们感兴趣的新平台/体系结构,例如Windows的 syscall 的软件包文档(在Linux上执行):

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

仅此而已.要快速检查它是否有效,请打印 DLL 类型及其方法:

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

示例输出:

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)

这记录在 syscall 包中:

详细信息取决于基础系统,默认情况下,godoc将显示当前系统的syscall文档.如果要godoc显示另一个系统的syscall文档,请将$ GOOS和$ GOARCH设置为所需的系统.例如,如果要在linux/amd64上查看freebsd/arm的文档,请将$ GOOS设置为freebsd,将$ GOARCH设置为arm.

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.

这篇关于如何访问平台特定的软件包文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆