You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
按照Go的 module proxy 规范,满足下列要求的 web 服务即可视为一个合格的module proxy:
技术细节,点击以展开
A Go module proxy is any web server that can respond to GET requests for
URLs of a specified form. The requests have no query parameters, so even
a site serving from a fixed file system (including a file:/// URL)
can be a module proxy.
The GET requests sent to a Go module proxy are:
GET $GOPROXY/<module>/@v/list returns a list of all known versions of the
given module, one per line.
GET $GOPROXY/<module>/@v/<version>.info returns JSON-formatted metadata
about that version of the given module.
GET $GOPROXY/<module>/@v/<version>.mod returns the go.mod file
for that version of the given module.
GET $GOPROXY/<module>/@v/<version>.zip returns the zip archive
for that version of the given module.
To avoid problems when serving from case-sensitive file systems,
the <module> and <version> elements are case-encoded, replacing every
uppercase letter with an exclamation mark followed by the corresponding
lower-case letter: github.com/Azure encodes as github.com/!azure.
The JSON-formatted metadata about a given module corresponds to
this Go data structure, which may be expanded in the future:
type Info struct {
Version string // version string
Time time.Time // commit time
}
The zip archive for a specific version of a given module is a
standard zip file that contains the file tree corresponding
to the module's source code and related files. The archive uses
slash-separated paths, and every file path in the archive must
begin with <module>@<version>/, where the module and version are
substituted directly, not case-encoded. The root of the module
file tree corresponds to the <module>@<version>/ prefix in the
archive.
Even when downloading directly from version control systems,
the go command synthesizes explicit info, mod, and zip files
and stores them in its local cache, $GOPATH/pkg/mod/cache/download,
the same as if it had downloaded them directly from a proxy.
The cache layout is the same as the proxy URL space, so
serving $GOPATH/pkg/mod/cache/download at (or copying it to)
https://example.com/proxy would let other users access those
cached module versions with GOPROXY=https://example.com/proxy.
注意: 由于 Go 提案 25530 (官方接受)的存在,Go proxy 还需要能够按一定规则返回依赖的 checksum 信息。
介绍
Golang 从1.11版本起支持以模块(Module)的形式管理依赖,并且支持下载依赖时使用镜像源以加速下载。
Golang的依赖并没有统一的上游(但镜像仍然可行,请参阅后文),常见上游为:
由于一些原因,国内网络环境难以访问其中的一些上游。
为什么希望添加该镜像
Golang 是一门在工程学和实际应用上都很优秀的语言,拥有广袤的云原生应用和生态。因为网络原因而无法获得这些优质依赖未免可惜。
如何实现镜像
按照Go的 module proxy 规范,满足下列要求的 web 服务即可视为一个合格的module proxy:
技术细节,点击以展开
注意: 由于 Go 提案 25530 (官方接受)的存在,Go proxy 还需要能够按一定规则返回依赖的 checksum 信息。
官方实现(没有开源)在:https://proxy.golang.org/
开源的镜像实现有:
也许贵站可以采用和参考。
备注
The text was updated successfully, but these errors were encountered: