-
Notifications
You must be signed in to change notification settings - Fork 391
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
问题:有没有可能给goproxy增加优先从本地文件缓存中提供sumdb的功能,支持偶尔完全断互联网时也能使用 #99
Comments
你好,首先抱歉这么久才回复你。由于这一阵子在忙的事情有点多,所以你的这个问题我就放在了 TODO 列表里,然后不小心就忘记了回答,实在是不好意思…… 如果你希望 goproxy.Goproxy.ProxiedSUMDBs 能够支持从 goproxy.Cacher 中存取数据,那我能告诉你的是我们并不能这样做。因为被代理的校验和数据库的内容都是可变的,所以将其缓存下来并不是一个正确的做法。 事实上,你遇到的问题很好解决,你只需要换个思路。 如果你的 Goproxy 服务是跑在公司内部,那么你可以为其指定好 大致代码如下: 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 作为上游代理
"GOSUMDB=sum.golang.google.cn", // 确保从上游拉取的模块数据都是可信任的
"GOPRIVATE=git.example.com", // 解决私有模块的拉取问题(比如可以配置成公司内部的代码源)
),
ProxiedSUMDBs: []string{
"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org", // 代理默认的校验和数据库
},
})
} |
你确定我们的常见问题页面中没有你想要询问的问题吗?
确定。
当你执行
go version
命令后的输出结果是什么?当你执行
go env
命令后的输出结果是什么?go env
的输出结果你做了什么?
编译了一个 goproxy,main.go 中缓存设置为了磁盘当前目录,
g.Cacher = &cacher.Disk{Root: ""}
,在连互联网的情况下拉取一些项目的依赖,让goproxy能缓存到磁盘。然后断开互联网,并删除 $GOPATH/pkg/mod 目录,并对所有工程重新执行 go build,希望能从本地goproxy的磁盘缓存中拉取依赖到 $GOPATH/pkg/mod 中并正常编译。
你期望看到的结果是什么?
期望看到可以正常拉取依赖并编译成功所有断网前拉取过依赖的项目。
你实际看到的结果是什么?
看上去本地的goproxy服务可以从磁盘缓存中Serve源代码,但没有从磁盘Serve sumdb,导致go build 工程时提示 :
有没有可能给goproxy增加优先从本地文件缓存中提供mod sum 信息的功能?
The text was updated successfully, but these errors were encountered: