Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

申请增加 Go 语言模块镜像(Go Module Mirror) #234

Closed
nanmu42 opened this issue Jul 5, 2019 · 3 comments
Closed

申请增加 Go 语言模块镜像(Go Module Mirror) #234

nanmu42 opened this issue Jul 5, 2019 · 3 comments

Comments

@nanmu42
Copy link

nanmu42 commented Jul 5, 2019

介绍

Golang 从1.11版本起支持以模块(Module)的形式管理依赖,并且支持下载依赖时使用镜像源以加速下载。

Golang的依赖并没有统一的上游(但镜像仍然可行,请参阅后文),常见上游为:

  • github.com
  • golang.org
  • cloud.google.com
  • google.golang.org

由于一些原因,国内网络环境难以访问其中的一些上游。

为什么希望添加该镜像

Golang 是一门在工程学和实际应用上都很优秀的语言,拥有广袤的云原生应用和生态。因为网络原因而无法获得这些优质依赖未免可惜。

如何实现镜像

按照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 信息。

官方实现(没有开源)在:https://proxy.golang.org/

开源的镜像实现有:

也许贵站可以采用和参考。

备注

@zhsj
Copy link
Contributor

zhsj commented Jul 5, 2019

如你备注所说,这和 #225 是重复的。

@zhsj zhsj closed this as completed Jul 5, 2019
@zhsj zhsj added the duplicate label Jul 5, 2019
@nanmu42
Copy link
Author

nanmu42 commented Jul 6, 2019

是的,意图是一样的。

这个Issue尝试更清晰地描述问题。

截止目前,投票人数达到48人了,希望贵站在计算 #255 的票数时,把这边的也加上。

@zhsj
Copy link
Contributor

zhsj commented Jul 6, 2019

这个Issue尝试更清晰地描述问题。

你可以回复原issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants