Repository: goproxy/goproxy.cn Branch: master Commit: 5ab915b8fec3 Files: 35 Total size: 328.3 KB Directory structure: gitextract_gsusttmj/ ├── .github/ │ ├── FUNDING.yaml │ └── ISSUE_TEMPLATE/ │ ├── bug-report.md │ ├── new-question.md │ └── new-question.zh-CN.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── LICENSE ├── README.md ├── README.zh-CN.md ├── assets/ │ ├── css/ │ │ ├── bootstrap.css │ │ └── main.css │ └── js/ │ └── main.js ├── base/ │ ├── base.go │ ├── retry.go │ └── time.go ├── config.toml ├── go.mod ├── go.sum ├── handler/ │ ├── goproxy.go │ ├── handler.go │ └── stat.go ├── locales/ │ ├── en-US.toml │ └── zh-CN.toml ├── main.go ├── robots.txt └── templates/ ├── index.html ├── index.zh-CN.html ├── layouts/ │ └── default.html ├── parts/ │ ├── footer.html │ ├── head.html │ ├── header.html │ └── scripts.html ├── stats.html └── stats.zh-CN.html ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yaml ================================================ github: aofei ================================================ FILE: .github/ISSUE_TEMPLATE/bug-report.md ================================================ --- name: Bug report about: Create a report to help us improve. title: 'Bug: ' labels: '' assignees: '' --- ## What is the output when you execute the `go version` command?
$ go version## What is the output when you execute the `go env` command?
go env Output$ go env
$ go version## What is the output when you execute the `go env` command?
go env Output$ go env
$ go version## 当你执行 `go env` 命令后的输出结果是什么?
go env 的输出结果$ go env
The most trusted Go module proxy in China.
{{.ModuleVersionCount}} module versions cached
StarWe are using Qiniu Cloud CDN to accelerate our service globally without placing any bandwidth limits. With thousands of CDN nodes and 100Gbps+ single-node bandwidth, you will be given the ability to download module versions at a blazing fast speed.
We do not just place no bandwidth limits. Furthermore, we have not placed any rate limits. This means that you can use our service in any scenario, like CI/CD. You can even use our service as an upstream proxy, just like goproxy.baidu.com does.
We are always using the latest Go version, even the unstable version. Because we provide cutting-edge feature support. In particular, we support proxying the default checksum database sum.golang.org. You don't need to do anything extra, it just works.
For everyone to better understand the activity of all modules in our service, we have launched the very first Statistics API of the Go module proxy world. With the decent RESTful API design, you will be able to easily query statistics for all module versions in our service.
Go 1.13 and above (RECOMMENDED)
Open your terminal and execute
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
done.
Open your terminal and execute
$ export GO111MODULE=on
$ export GOPROXY=https://goproxy.cn
or
$ echo "export GO111MODULE=on" >> ~/.profile
$ echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
$ source ~/.profile
done.
Open your terminal and execute
C:\> $env:GO111MODULE = "on"
C:\> $env:GOPROXY = "https://goproxy.cn"
or
1. Open the Start Search, type in "env"
2. Choose the "Edit the system environment variables"
3. Click the "Environment Variables…" button
4. Under the "User variables for <YOUR_USERNAME>" section (the upper half)
5. Click the "New..." button
6. Choose the "Variable name" input bar, type in "GO111MODULE"
7. Choose the "Variable value" input bar, type in "on"
8. Click the "OK" button
9. Click the "New..." button
10. Choose the "Variable name" input bar, type in "GOPROXY"
11. Choose the "Variable value" input bar, type in "https://goproxy.cn"
12. Click the "OK" button
done.
Your code is always yours, so we provide you with the coolest self-hosted Go module proxy building solution in the world. By using Goproxy, a minimalist project, you can easily add Go module proxy support to any existing web service, you know that Goproxy.cn is built on it.
Create a file named goproxy.go
package main
import (
"net/http"
"os"
"github.com/goproxy/goproxy"
)
func main() {
http.ListenAndServe("localhost:8080", &goproxy.Goproxy{
GoBinEnv: append(
os.Environ(),
"GOPROXY=https://goproxy.cn,direct", // Use Goproxy.cn as the upstream proxy
"GOPRIVATE=git.example.com", // Solve the problem of pulling private modules
),
ProxiedSUMDBs: []string{
"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org", // Proxy the default checksum database
},
})
}
and run it
$ go run goproxy.go
then try it by setting GOPROXY to http://localhost:8080. In addition, we also recommend that you set GO111MODULE to on.
That's it, a fully functional Go module proxy is successfully built. In fact, you can use Goproxy with your favorite web frameworks, such as Gin and Echo, all you need to do is add one more route. For more advanced usage please check the documentation.
我们正在使用七牛云 CDN 在全球范围内加速我们的服务,并且我们没有设置任何带宽限制。凭借着数以千计的 CDN 节点和 100Gbps+ 的单节点带宽,你将被赋予一个以极快的速度下载模块版本的能力。
我们不但没有设置带宽限制。更进一步地,我们还没有设置任何速率限制。这意味着你可以在任何场景下使用我们的服务,例如 CI/CD。你甚至可以像 goproxy.baidu.com 一样将我们的服务用作上游代理。
我们一直在使用最新的 Go 版本,甚至是不稳定版本,因此我们提供了最前沿的功能支持。特别地,我们支持代理默认的校验和数据库 sum.golang.org。你无需进行其他额外的配置,它便可以正常工作。
为了使大家可以更好地了解我们的服务中所有模块的活跃度,我们推出了 Go 模块代理世界中的首个统计数据 API。通过得体的 RESTful API 设计,你将能够轻松地查询我们服务中所有模块版本的统计数据。
打开你的终端并执行
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
完成。
打开你的终端并执行
$ export GO111MODULE=on
$ export GOPROXY=https://goproxy.cn
或者
$ echo "export GO111MODULE=on" >> ~/.profile
$ echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
$ source ~/.profile
完成。
打开你的 PowerShell 并执行
C:\> $env:GO111MODULE = "on"
C:\> $env:GOPROXY = "https://goproxy.cn"
或者
1. 打开“开始”并搜索“env”
2. 选择“编辑系统环境变量”
3. 点击“环境变量…”按钮
4. 在“<你的用户名> 的用户变量”章节下(上半部分)
5. 点击“新建…”按钮
6. 选择“变量名”输入框并输入“GO111MODULE”
7. 选择“变量值”输入框并输入“on”
8. 点击“确定”按钮
9. 点击“新建…”按钮
10. 选择“变量名”输入框并输入“GOPROXY”
11. 选择“变量值”输入框并输入“https://goproxy.cn”
12. 点击“确定”按钮
完成。
你的代码永远只属于你自己,因此我们向你提供目前世界上最炫酷的自托管 Go 模块代理搭建方案。通过使用 Goproxy 这个极简主义项目,你可以在现有的任意 Web 服务中轻松地引入 Go 模块代理支持,要知道 Goproxy.cn 就是基于它搭建的。
创建一个名为 goproxy.go 的文件
package main
import (
"net/http"
"os"
"github.com/goproxy/goproxy"
)
func main() {
http.ListenAndServe("localhost:8080", &goproxy.Goproxy{
GoBinEnv: append(
os.Environ(),
"GOPROXY=https://goproxy.cn,direct", // 使用 Goproxy.cn 作为上游代理
"GOPRIVATE=git.example.com", // 解决私有模块的拉取问题(比如可以配置成公司内部的代码源)
),
ProxiedSUMDBs: []string{
"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org", // 代理默认的校验和数据库
},
})
}
并且运行它
$ go run goproxy.go
然后通过把 GOPROXY 设置为 http://localhost:8080 来试用它。另外,我们也建议你把 GO111MODULE 设置为 on。
就这么简单,一个功能完备的 Go 模块代理就搭建成功了。事实上,你还可以将 Goproxy 结合着你钟爱的 Web 框架一起使用,比如 Gin 和 Echo,你所需要做的只是多添加一条路由而已。更高级的用法请查看文档。
Get the summary information of the service, such as the total size and total number of all module versions in the service.
GET /stats/summary
Example request URL: goproxy.cn/stats/summary
Example response body:
{
"cacher_size": 2663405247231,
"module_version_count": 1035421,
"module_host_count": 1120,
"top_10_module_hosts": [
{"module_host": "github.com", "module_version_count": 921606},
{"module_host": "k8s.io", "module_version_count": 24982},
{"module_host": "gitlab.com", "module_version_count": 13172},
{"module_host": "gopkg.in", "module_version_count": 10479},
{"module_host": "golang.org", "module_version_count": 8000},
{"module_host": "gitee.com", "module_version_count": 4650},
{"module_host": "bitbucket.org", "module_version_count": 4177},
{"module_host": "sigs.k8s.io", "module_version_count": 3280},
{"module_host": "google.golang.org", "module_version_count": 2703},
{"module_host": "istio.io", "module_version_count": 2487}
]
}
Get module trends in service, such as the most active top 1000 module in the most recent period.
GET /stats/trends/<trend>
The path parameter <trend> is REQUIRED and has three options: latest (latest trend), last-7-days (trend in the last 7 days), and last-30-days (trend in the last 30 days).
Example request URL: goproxy.cn/stats/trends/latest
Example response body:
[
{"module_path": "golang.org/x/sys", "download_count": 1822180},
{"module_path": "golang.org/x/net", "download_count": 1713080},
{"module_path": "golang.org/x/tools", "download_count": 1503522},
{"module_path": "golang.org/x/crypto", "download_count": 1032270},
{"module_path": "gopkg.in/yaml.v2", "download_count": 578120}
]
Get the statistics of the specified module (version) in the service, such as the total number of downloads of the specified module (version) and its single-day downloads in the last 30 days.
GET /stats/<module-path>[@<module-version>]
The path parameter <module-path> is REQUIRED, for example: golang.org/x/text.
The path parameter <module-version> is OPTIONAL, and note that it can only appear with the leading symbol @, for example: @v0.3.2.
Example request URL: goproxy.cn/stats/golang.org/x/text
Example response body:
{
"download_count": 476705,
"last_30_days": [
{"date": "2020-03-25T00:00:00Z", "download_count": 15940},
{"date": "2020-03-24T00:00:00Z", "download_count": 16884},
{"date": "2020-03-23T00:00:00Z", "download_count": 15842},
{"date": "2020-03-22T00:00:00Z", "download_count": 11232},
{"date": "2020-03-21T00:00:00Z", "download_count": 11894},
{"date": "2020-03-20T00:00:00Z", "download_count": 14968},
{"date": "2020-03-19T00:00:00Z", "download_count": 11017},
{"date": "2020-03-18T00:00:00Z", "download_count": 5209},
{"date": "2020-03-17T00:00:00Z", "download_count": 5759},
{"date": "2020-03-16T00:00:00Z", "download_count": 4166},
{"date": "2020-03-15T00:00:00Z", "download_count": 2145},
{"date": "2020-03-14T00:00:00Z", "download_count": 2218},
{"date": "2020-03-13T00:00:00Z", "download_count": 4609},
{"date": "2020-03-12T00:00:00Z", "download_count": 5503},
{"date": "2020-03-11T00:00:00Z", "download_count": 5412},
{"date": "2020-03-10T00:00:00Z", "download_count": 6453},
{"date": "2020-03-09T00:00:00Z", "download_count": 4798},
{"date": "2020-03-08T00:00:00Z", "download_count": 2323},
{"date": "2020-03-07T00:00:00Z", "download_count": 2332},
{"date": "2020-03-06T00:00:00Z", "download_count": 4806},
{"date": "2020-03-05T00:00:00Z", "download_count": 6339},
{"date": "2020-03-04T00:00:00Z", "download_count": 5858},
{"date": "2020-03-03T00:00:00Z", "download_count": 5579},
{"date": "2020-03-02T00:00:00Z", "download_count": 8862},
{"date": "2020-03-01T00:00:00Z", "download_count": 2119},
{"date": "2020-02-29T00:00:00Z", "download_count": 2053},
{"date": "2020-02-28T00:00:00Z", "download_count": 4735},
{"date": "2020-02-27T00:00:00Z", "download_count": 6578},
{"date": "2020-02-26T00:00:00Z", "download_count": 4954},
{"date": "2020-02-25T00:00:00Z", "download_count": 5318}
],
"top_10_module_versions": [
{"module_version": "v0.3.2", "download_count": 232795},
{"module_version": "v0.3.0", "download_count": 146009},
{"module_version": "v0.3.1-0.20180807135948-17ff2d5776d2", "download_count": 67096},
{"module_version": "v0.3.1-0.20181227161524-e6919f6577db", "download_count": 11494},
{"module_version": "v0.0.0-20160726164857-2910a502d2bf", "download_count": 11223},
{"module_version": "v0.0.0-20170915032832-14c0d48ead0c", "download_count": 3991},
{"module_version": "v0.3.1-0.20171227012246-e19ae1496984", "download_count": 1128},
{"module_version": "v0.0.0-20170915090833-1cbadb444a80", "download_count": 937},
{"module_version": "v0.3.1-0.20181030141323-6f44c5a2ea40", "download_count": 480},
{"module_version": "v0.3.1", "download_count": 353}
]
}
Example request URL: goproxy.cn/stats/golang.org/x/text@v0.3.2
Example response body:
{
"download_count": 232795,
"last_30_days": [
{"date": "2020-03-25T00:00:00Z", "download_count": 12852},
{"date": "2020-03-24T00:00:00Z", "download_count": 12708},
{"date": "2020-03-23T00:00:00Z", "download_count": 12602},
{"date": "2020-03-22T00:00:00Z", "download_count": 10371},
{"date": "2020-03-21T00:00:00Z", "download_count": 10673},
{"date": "2020-03-20T00:00:00Z", "download_count": 11882},
{"date": "2020-03-19T00:00:00Z", "download_count": 8379},
{"date": "2020-03-18T00:00:00Z", "download_count": 2244},
{"date": "2020-03-17T00:00:00Z", "download_count": 2407},
{"date": "2020-03-16T00:00:00Z", "download_count": 1696},
{"date": "2020-03-15T00:00:00Z", "download_count": 981},
{"date": "2020-03-14T00:00:00Z", "download_count": 897},
{"date": "2020-03-13T00:00:00Z", "download_count": 1898},
{"date": "2020-03-12T00:00:00Z", "download_count": 2498},
{"date": "2020-03-11T00:00:00Z", "download_count": 2374},
{"date": "2020-03-10T00:00:00Z", "download_count": 2491},
{"date": "2020-03-09T00:00:00Z", "download_count": 1854},
{"date": "2020-03-08T00:00:00Z", "download_count": 800},
{"date": "2020-03-07T00:00:00Z", "download_count": 981},
{"date": "2020-03-06T00:00:00Z", "download_count": 2085},
{"date": "2020-03-05T00:00:00Z", "download_count": 2642},
{"date": "2020-03-04T00:00:00Z", "download_count": 2212},
{"date": "2020-03-03T00:00:00Z", "download_count": 2515},
{"date": "2020-03-02T00:00:00Z", "download_count": 2832},
{"date": "2020-03-01T00:00:00Z", "download_count": 785},
{"date": "2020-02-29T00:00:00Z", "download_count": 871},
{"date": "2020-02-28T00:00:00Z", "download_count": 2019},
{"date": "2020-02-27T00:00:00Z", "download_count": 2480},
{"date": "2020-02-26T00:00:00Z", "download_count": 2163},
{"date": "2020-02-25T00:00:00Z", "download_count": 2344}
]
}
Get the badge for the total download of the specified module in the service.
GET /stats/<module-path>/badges/download-count.svg
The path parameter <module-path> is REQUIRED, for example: golang.org/x/text.
Example request URL: goproxy.cn/stats/golang.org/x/text/badges/download-count.svg
Example response body:
The total download badge for a specified module can be placed in the project's README.md using the following Markdown syntax:
[](https://goproxy.cn)
获取服务的摘要信息,如服务中所有模块版本的总尺寸和总数等。
GET /stats/summary
示例请求 URL:goproxy.cn/stats/summary
示例响应主体:
{
"cacher_size": 2663405247231,
"module_version_count": 1035421,
"module_host_count": 1120,
"top_10_module_hosts": [
{"module_host": "github.com", "module_version_count": 921606},
{"module_host": "k8s.io", "module_version_count": 24982},
{"module_host": "gitlab.com", "module_version_count": 13172},
{"module_host": "gopkg.in", "module_version_count": 10479},
{"module_host": "golang.org", "module_version_count": 8000},
{"module_host": "gitee.com", "module_version_count": 4650},
{"module_host": "bitbucket.org", "module_version_count": 4177},
{"module_host": "sigs.k8s.io", "module_version_count": 3280},
{"module_host": "google.golang.org", "module_version_count": 2703},
{"module_host": "istio.io", "module_version_count": 2487}
]
}
获取服务中的模块趋势,如最近一段时间内最活跃的最多前 1000 个模块。
GET /stats/trends/<trend>
路径参数 <trend> 是必填的,它拥有三个选项:latest(最新趋势)、last-7-days(最近 7 天的趋势)和 last-30-days(最近 30 天的趋势)。
示例请求 URL:goproxy.cn/stats/trends/latest
示例响应主体:
[
{"module_path": "golang.org/x/sys", "download_count": 1822180},
{"module_path": "golang.org/x/net", "download_count": 1713080},
{"module_path": "golang.org/x/tools", "download_count": 1503522},
{"module_path": "golang.org/x/crypto", "download_count": 1032270},
{"module_path": "gopkg.in/yaml.v2", "download_count": 578120}
]
获取服务中指定模块(版本)的统计,如指定模块(版本)的总下载次数和其在最近 30 天内的单日下载次数。
GET /stats/<module-path>[@<module-version>]
路径参数 <module-path> 是必填的,如:golang.org/x/text。
路径参数 <module-version> 是可选的,并且需要注意它只能伴随着前导符号 @ 一起出现,如:@v0.3.2。
示例请求 URL:goproxy.cn/stats/golang.org/x/text
示例响应主体:
{
"download_count": 476705,
"last_30_days": [
{"date": "2020-03-25T00:00:00Z", "download_count": 15940},
{"date": "2020-03-24T00:00:00Z", "download_count": 16884},
{"date": "2020-03-23T00:00:00Z", "download_count": 15842},
{"date": "2020-03-22T00:00:00Z", "download_count": 11232},
{"date": "2020-03-21T00:00:00Z", "download_count": 11894},
{"date": "2020-03-20T00:00:00Z", "download_count": 14968},
{"date": "2020-03-19T00:00:00Z", "download_count": 11017},
{"date": "2020-03-18T00:00:00Z", "download_count": 5209},
{"date": "2020-03-17T00:00:00Z", "download_count": 5759},
{"date": "2020-03-16T00:00:00Z", "download_count": 4166},
{"date": "2020-03-15T00:00:00Z", "download_count": 2145},
{"date": "2020-03-14T00:00:00Z", "download_count": 2218},
{"date": "2020-03-13T00:00:00Z", "download_count": 4609},
{"date": "2020-03-12T00:00:00Z", "download_count": 5503},
{"date": "2020-03-11T00:00:00Z", "download_count": 5412},
{"date": "2020-03-10T00:00:00Z", "download_count": 6453},
{"date": "2020-03-09T00:00:00Z", "download_count": 4798},
{"date": "2020-03-08T00:00:00Z", "download_count": 2323},
{"date": "2020-03-07T00:00:00Z", "download_count": 2332},
{"date": "2020-03-06T00:00:00Z", "download_count": 4806},
{"date": "2020-03-05T00:00:00Z", "download_count": 6339},
{"date": "2020-03-04T00:00:00Z", "download_count": 5858},
{"date": "2020-03-03T00:00:00Z", "download_count": 5579},
{"date": "2020-03-02T00:00:00Z", "download_count": 8862},
{"date": "2020-03-01T00:00:00Z", "download_count": 2119},
{"date": "2020-02-29T00:00:00Z", "download_count": 2053},
{"date": "2020-02-28T00:00:00Z", "download_count": 4735},
{"date": "2020-02-27T00:00:00Z", "download_count": 6578},
{"date": "2020-02-26T00:00:00Z", "download_count": 4954},
{"date": "2020-02-25T00:00:00Z", "download_count": 5318}
],
"top_10_module_versions": [
{"module_version": "v0.3.2", "download_count": 232795},
{"module_version": "v0.3.0", "download_count": 146009},
{"module_version": "v0.3.1-0.20180807135948-17ff2d5776d2", "download_count": 67096},
{"module_version": "v0.3.1-0.20181227161524-e6919f6577db", "download_count": 11494},
{"module_version": "v0.0.0-20160726164857-2910a502d2bf", "download_count": 11223},
{"module_version": "v0.0.0-20170915032832-14c0d48ead0c", "download_count": 3991},
{"module_version": "v0.3.1-0.20171227012246-e19ae1496984", "download_count": 1128},
{"module_version": "v0.0.0-20170915090833-1cbadb444a80", "download_count": 937},
{"module_version": "v0.3.1-0.20181030141323-6f44c5a2ea40", "download_count": 480},
{"module_version": "v0.3.1", "download_count": 353}
]
}
示例请求 URL:goproxy.cn/stats/golang.org/x/text@v0.3.2
示例响应主体:
{
"download_count": 232795,
"last_30_days": [
{"date": "2020-03-25T00:00:00Z", "download_count": 12852},
{"date": "2020-03-24T00:00:00Z", "download_count": 12708},
{"date": "2020-03-23T00:00:00Z", "download_count": 12602},
{"date": "2020-03-22T00:00:00Z", "download_count": 10371},
{"date": "2020-03-21T00:00:00Z", "download_count": 10673},
{"date": "2020-03-20T00:00:00Z", "download_count": 11882},
{"date": "2020-03-19T00:00:00Z", "download_count": 8379},
{"date": "2020-03-18T00:00:00Z", "download_count": 2244},
{"date": "2020-03-17T00:00:00Z", "download_count": 2407},
{"date": "2020-03-16T00:00:00Z", "download_count": 1696},
{"date": "2020-03-15T00:00:00Z", "download_count": 981},
{"date": "2020-03-14T00:00:00Z", "download_count": 897},
{"date": "2020-03-13T00:00:00Z", "download_count": 1898},
{"date": "2020-03-12T00:00:00Z", "download_count": 2498},
{"date": "2020-03-11T00:00:00Z", "download_count": 2374},
{"date": "2020-03-10T00:00:00Z", "download_count": 2491},
{"date": "2020-03-09T00:00:00Z", "download_count": 1854},
{"date": "2020-03-08T00:00:00Z", "download_count": 800},
{"date": "2020-03-07T00:00:00Z", "download_count": 981},
{"date": "2020-03-06T00:00:00Z", "download_count": 2085},
{"date": "2020-03-05T00:00:00Z", "download_count": 2642},
{"date": "2020-03-04T00:00:00Z", "download_count": 2212},
{"date": "2020-03-03T00:00:00Z", "download_count": 2515},
{"date": "2020-03-02T00:00:00Z", "download_count": 2832},
{"date": "2020-03-01T00:00:00Z", "download_count": 785},
{"date": "2020-02-29T00:00:00Z", "download_count": 871},
{"date": "2020-02-28T00:00:00Z", "download_count": 2019},
{"date": "2020-02-27T00:00:00Z", "download_count": 2480},
{"date": "2020-02-26T00:00:00Z", "download_count": 2163},
{"date": "2020-02-25T00:00:00Z", "download_count": 2344}
]
}
获取服务中指定模块的总下载次数徽章。
GET /stats/<module-path>/badges/download-count.svg
路径参数 <module-path> 是必填的,如:golang.org/x/text。
示例请求 URL:goproxy.cn/stats/golang.org/x/text/badges/download-count.svg
示例响应主体:
可以通过如下 Markdown 语法将指定模块的总下载次数徽章放入项目的 README.md 中:
[](https://goproxy.cn)