github 倉庫 : https://github.com/whtiehack/goproxy
用 goproxy 自建 go modules 代理,部署到 heroku
- 點擊下面這個按鈕(或者先fork再點,這樣可以自己修改部署腳本)
用 goproxy 在 heroku 自建 go modules 代理。
App name 是一個唯一的 app名字
Choose a region 有美國和歐洲可以選。個人認爲美國的速度還不錯。會在region裏隨機分配一個節點給你,有的節點很快,有的比較慢。不過還是會比 goproxy.io 之類的快。
點 Create app ,等一會就部署完成了。
- 現在你就可以使用你自建的 go modules 代理了。
linux:
export GOPROXY=https://youappname.herokuapp.com
windows:
$env:GOPROXY = "https://youappname.herokuapp.com"
- Now, when you build and run your applications, go will fetch dependencies via
https://youappname.herokuapp.com
.
Note: This proxy can’t fetch your private repos of course.
youappname
是你Crate New App 時的 App name
- 直接打開你申請的鏈接應該是顯示空白。
可以用這個鏈接測試一下: https://youappname.herokuapp.com/github.com/nsqio/nsq/@v/list
- heroku 部署的 app,在一段時間內沒有流量會被凍結。然後有人訪問的時候就纔會再次啓動。(所以第一次打開會比較慢,啓動好了就快了)
- 提供一個懶人用測試地址,多人用不能保證速度,而且每個月是有限額的(一個人單獨用完全足夠)。所以還是建議自己 fork 自己建立一個 app。 https://goproxyus.herokuapp.com
額外的功能
- 可以用這個代理下載倉庫
- https://goproxyus.herokuapp.com/github.com/whtiehack/goproxy/@latest
- https://goproxyus.herokuapp.com/github.com/whtiehack/goproxy/@v/v0.0.0-20190429094219-4f70e1c14471.zip
- latest 有個問題,不會再次去拿最新代碼。
或者你知道明確版本的放可以構造url直接下載 : https://goproxyus.herokuapp.com/github.com/node-pinus/pinus/@v/v1.3.10.zip
- 被緩存下來的數據可以打開 https://goproxyus.herokuapp.com 直接瀏覽並下載。
現有的可用的其它代理:
export GOPROXY="https://athens.azurefd.net"
export GOPROXY="https://goproxy.io"
export GOPROXY="https://goproxyus.herokuapp.com"
export GOPROXY="https://goproxy.cn"
# 最新官方的
export GOPROXY="https://proxy.golang.org"
別忘記開啓golang的 modules 特性。