V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
nanmu42
V2EX  ›  Go 编程语言

欢迎关注和投票:申请中科大镜像站提供 Golang 模块(依赖)镜像服务

  •  1
     
  •   nanmu42 ·
    nanmu42 · 2019-07-05 12:17:11 +08:00 · 2800 次点击
    这是一个创建于 1964 天前的主题,其中的信息可能已经有所发展或是发生改变。

    投票方式

    下面是对提案的全文转载:

    介绍

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

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

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

    为什么希望添加该镜像

    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/

    开源的镜像实现有:

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

    备注

    • 相关的 Issue: #225 .
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5745 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 01:42 · PVG 09:42 · LAX 17:42 · JFK 20:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.