Coder Social home page Coder Social logo

goproxy / goproxy Goto Github PK

View Code? Open in Web Editor NEW
1.2K 12.0 116.0 513 KB

A minimalist Go module proxy handler.

Home Page: https://pkg.go.dev/github.com/goproxy/goproxy

License: MIT License

Go 99.49% Dockerfile 0.51%
goproxy minimalist go module proxy handler

goproxy's Introduction

Goproxy

Test codecov Go Report Card PkgGoDev

A minimalist Go module proxy handler.

Goproxy has fully implemented the GOPROXY protocol. The goal of this project is to find the most dead simple way to provide a minimalist handler that can act as a full-featured Go module proxy for those who want to build their own proxies.

Features

Installation

  • To use this project programmatically, go get it:
go get github.com/goproxy/goproxy
  • To use this project from the command line, download the pre-built binaries from here or build it from source:
go install github.com/goproxy/goproxy/cmd/goproxy@latest
  • To use this project with Docker, pull the pre-built images from here:
docker pull ghcr.io/goproxy/goproxy

Quick Start

Write code

Create a file named goproxy.go:

package main

import (
	"net/http"

	"github.com/goproxy/goproxy"
)

func main() {
	http.ListenAndServe("localhost:8080", &goproxy.Goproxy{})
}

Then run it with a GOMODCACHE that differs from go env GOMODCACHE:

GOMODCACHE=/tmp/goproxy-gomodcache go run goproxy.go

Finally, set GOPROXY to try it out:

go env -w GOPROXY=http://localhost:8080,direct

For more details, refer to the documentation.

Run from command line

Refer to the Installation section to download or build the binary.

Then run it with a GOMODCACHE that differs from go env GOMODCACHE:

GOMODCACHE=/tmp/goproxy-gomodcache goproxy server --address localhost:8080

Finally, set GOPROXY to try it out:

go env -w GOPROXY=http://localhost:8080,direct

For more details, check its usage:

goproxy --help
Run with Docker

Refer to the Installation section to pull the image.

Then run it:

docker run -p 8080:8080 ghcr.io/goproxy/goproxy server --address :8080

Finally, set GOPROXY to try it out:

go env -w GOPROXY=http://localhost:8080,direct

For more details, check its usage:

docker run ghcr.io/goproxy/goproxy --help

Community

If you have any questions or ideas about this project, feel free to discuss them here.

Contributing

If you would like to contribute to this project, please submit issues here or pull requests here.

License

This project is licensed under the MIT License.

goproxy's People

Contributors

aofei avatar dependabot[bot] avatar lwalen avatar sgtcodfish avatar vrischmann avatar wizardishungry avatar zhangyunhao116 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goproxy's Issues

pipe character support problems

Look like we have not implemented this feature correctly. For example
g.GoBinEnv = append(os.Environ(), "GOPROXY=http://baidu.com|https://goproxy.io")
and curl this link
http://0.0.0.0:8080/github.com/google/go-dap/@v/v0.2.0.mod
we can got an error
github.com/google/[email protected]: malformed record data

The reason is that we skip errors in sumdb_client_ops.go:(sco *sumdbClientOps) load(), this function only called at initialization, but this error occurred in goproxy.go:zipLines, err := g.sumdbClient.Lookup, which called during fetching. Maybe we should skip errors after g.sumdbClient.Lookup?

Go1.15 implements this feature in https://github.com/golang/go/blob/release-branch.go1.15/src/cmd/go/internal/modfetch/proxy.go#L196 may have some help.

GoBinEnv GORPIVATE can't effect

`package main

import (
"net/http"
"os"
"github.com/goproxy/goproxy"
)

func main(){
g := goproxy.New()
g.GoBinEnv = append(
os.Environ(),
"GOPROXY=https://goproxy.cn,direct", // 使用 goproxy.cn 作为上游代理
"GOPRIVATE=gitlab.xx.com", // 解决私有模块的拉取问题(比如可以配置成公司内部的代码源)
)
g.ProxiedSUMDBs = []string{"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org"} // 代理默认的校验和数据库
http.ListenAndServe("0.0.0.0:80", g)
}
`

MITM

Is it correct that this does not support MITM as the original goproxy does?

拉取私有仓库问题

在做了私有仓库转发后包可以正常被拉去,但是以.git为前缀的文件都被删除了
例如:原文件.gitignore 拉下来后变为ignore
期待大佬的解答

redirect from goproxy.io

I run a local goproxy at my server: goproxy -proxy=https://goproxy.io .

I created a golang test project, and set my $GOPROXY=mygoproxyweb, sine I run go build , I encountered a 302 redirect response from my goproxy:
Location https://goproxy.someimg.com/github.com/gin-gonic/gin/@v/v1.5.0.zip
It's very strange, I didn't find any string "someimg.com" in the goproxy code.

Is it a feature of product enviroment https://goproxy.io ?

I changed the upstream proxy to gocenter.io, It works well.
goproxy -proxy=https://gocenter.io .

Unable to complete go get command when GOPROXY=direct

I've run into an issue using this configuration
The issue is that if I push a new version of a module and try to perform go get then it doesn't find the new version unless I perform a go mod download first.

g := goproxy.Goproxy{}
dirCacher := goproxy.DirCacher(cacheDir)
g.Cacher = dirCacher
g.GoBinEnv = append(
os.Environ(),
"GOPROXY=https://proxy.golang.org,direct",
"GOPRIVATE=go.mine.com",
)
g.ProxiedSUMDBs = []string{"sum.golang.org"}
IP := ""
fmt.Printf("Listening on ...%s:%s\nCache %v\n", IP, strconv.FormatInt(port, 10), cacheDir)
fmt.Println("GoBinEnv: ")
for _,v := range g.GoBinEnv {
if strings.HasPrefix(v, "GO") {
fmt.Printf("%v\n", v)
}
}

log.Println("running...")
if err := http.ListenAndServe(fmt.Sprintf("%s:%s", IP, strconv.FormatInt(port, 10)), &g); err != nil {
log.Println(err)
}

If I change the GOPROXY from this
"GOPROXY=https://proxy.golang.org,direct",
to this
"GOPROXY=direct",

then it say's downloading but then never completes.

failed to list module versions

failed to list module versions: google.golang.org/protobuf/types@latest: go: module google.golang.org/protobuf/types: no matching versions for query "latest"

[BUG] go get stuck and server output git error

I have set up a server on localhost:9080 using goproxy, but it gets stuck when I try to execute go get.

client:

GOPROXY=http://localhost:9080 go get gitlab.xxx.com/aaa/bbb@latest
go: downloading gitlab.xxx.com/aaa/bbb v0.0.0-20230815123511-328a75f65a51

server log:

2023/08/31 19:01:53 goproxy.go:391: goproxy: failed to list module version: gitlab.xxx.com/@v/list: module xxx.com: git ls-remote -q origin in /Users/adl/go/pkg/mod/cache/vcs/73e7c5efccc154f70f696b7ea0cb7a2a8e4f7960832a7bf61d0232685fc3163e: exit status 128:
	fatal: no path specified; see 'git help pull' for valid url syntax
2023/08/31 19:01:54 goproxy.go:391: goproxy: failed to list module version: gitlab.xxx.com/bbb/@v/list: module gitlab.xxx/bbb: git ls-remote -q origin in /Users/adl/go/pkg/mod/cache/vcs/f56dcfdca177b425cf074e4d7907ec28d80ec30aee1b92f4f93290aa4b447dec: exit status 128:
	fatal: protocol error: bad line length character: repo

server code:

	http.ListenAndServe(":9080", &goproxy.Goproxy{
		GoBinEnv: append(
			os.Environ(),
			"GOPROXY=https://goproxy.cn",  // 使用 Goproxy.cn 作为上游代理
			"GOPRIVATE=*.xxx.com", // 解决私有模块的拉取问题(比如可以配置成公司内部的代码源)
		),
		ProxiedSUMDBs: []string{
			"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org", // 代理默认的校验和数据库
		},
		ErrorLogger: logger,
	})

ENV:

$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/adl/Library/Caches/go-build"
GOENV="/Users/adl/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/adl/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/adl/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bj/t_584mj969b8zchzmqh_l4xh0000gp/T/go-build3868987923=/tmp/go-build -gno-record-gcc-switches -fno-common"

$ git version
git version 2.39.2 (Apple Git-143)

connections staying open

I am working on a way to run multiple vpns on the same machine and so I need to be able to close tcp connections as soon as possible

proxy := goproxy.NewProxyHttpServer()
	//proxy.OnRequest().HandleConnect(goproxy.AlwaysMitm)
	proxy.Verbose = true // Set to true to see all proxy traffic

	customDial := func(network, addr string) (net.Conn, error) {
        conn, err := net.Dial(network, addr)
        if err != nil {
            return nil, err
        }

        log.Println("Connection made (TCP)")

        return &onCloseConn{Conn: conn}, nil
    }

    // Set the custom dial function for HTTP traffic
    proxy.Tr = &http.Transport{
    	Dial: customDial,
    	DisableKeepAlives :true,
    	MaxIdleConns :0,
    	IdleConnTimeout:     1 * time.Millisecond,
    }

    proxy.ConnectDial = customDial
runing a simple test shows the connection stays open. even tho the request is done and the client process that made it is terminated. 
it would eventualy die but it takes quite a while

/tmp required but not configurable

When running goproxy in a from scratch container it will fail to serve with the following message:

stat /tmp: no such file or directory

Client side it will be:

go mod download: github.com/aws/[email protected]: reading http://<proxy-url>/github.com/aws/aws-sdk-go/@v/v1.34.31.info: 500 Internal Server Error

I can't find in the go source the /tmp hardcoded anywhere, as such it is likely from an upstream library.

Maybe mentioning this in the documentation is good enough

Proxy not working properly

Right now when I try to use go get, the proxy cannot parse the git URLs properly.

For example, if I run

go get github.com/bazelbuild/bazelisk

I obtain this in the proxy handler

2019/11/21 15:17:43 mod list github.com/bazelbuild@latest: go list -m: github.com/bazelbuild@latest: invalid github.com/ import path "github.com/bazelbuild"
2019/11/21 15:17:43 mod list github.com@latest: go list -m: github.com@latest: unrecognized import path "github.com" (parse https://github.com/?go-get=1: no go-import meta tags ())

Any clues on what is causing the issue? Am missing the setup of something?

goproxy responds with HTTP/1.0 on response to CONNECT, some clients do not support this

Hello,

While using the Erlang HTTP client gun, I'm unable to make a successful connection to smokescreen. gun is expecting the proxy server to respond only with HTTP/1.1 on the response to the CONNECT, but goproxy is providing HTTP/1.0.

I've reached out to the maintainer of gun[0] with the possibility of allowing this case on the client with an optional flag. But I also wanted to check in here to see if there is anything to address within goproxy.

Thanks,
Jesse

[0] gun:connect expects proxy server to reply with HTTP/1.1...

请求某个资源时容易出现500错误

现象
我们基于[email protected]版本搭建的了内部goproxy服务,代码如下:

package main

import (
	"github.com/goproxy/goproxy"
	"net/http"
	"os"
)

func main() {
	http.ListenAndServe(":9080", &goproxy.Goproxy{
		GoBinEnv: append(
			os.Environ(),
			"GOPROXY=https://goproxy.cn",  // 使用 Goproxy.cn 作为上游代理
			"GOPRIVATE=*.xxx.com", // 解决私有模块的拉取问题(配置成公司内部的代码源)
		),
		ProxiedSUMDBs: []string{
			"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org", // 代理默认的校验和数据库
		},
	})
}

基于go-1.16.1编译后,部署了若干台机器。运行一段时间后,接到反馈拉取某些golang模块会出现500错误,例如:
curl "http://127.0.0.1:9080/github.com/bombsimon/logrusr/@v/v1.0.0.mod"
会返回错误:
"internal server error"
状态码是500
但访问其他资源是ok的,就是某些资源始终都是这个500错误(其他机器上正常)。
然后,重启goproxy服务后,再curl则正常了。

** 问题频率 **
随机在不同的机器上都出现这个问题,访问某些资源(资源有随机性,基本是github.com的)时500错误。
重启后在1个星期到2天之间就会重新出现此问题。
我采取的应对措施是:针对出现了500错误的资源url进行监控,发现500则重启goproxy
但后来发现这个方法也不能保证服务稳定性,因为总是有各种各样的github.com的资源会出现500,
试图查后端日志,发现也没有什么有价值的日志,几乎就是一句 internal server error

期望
有更多的日志指引如何避免此问题
或者提升goproxy的健壮性。

support /@latest endpoint

According to GOPROXY protocol, /@latest is optional, but it is helpful if can add it.
The use case will be any usage without the go sub-command, like request the endpoint from HTTP.

支持导入路径的替换功能

支持导入路径的替换功能

概念

原始导入路径(original import path): 代码中的导入路径
实际导入路径(actual import path): 引用代码实际的导入路径

举例

线上仓库地址为: code.haormj.xyz/go/dispatcher
本地项目导入路径为: haormj.xyz/go/dispatcher

目前要迁移到 go mod

方案一

go.mod中配置 replace 解决

module haormj.xyz/go/test

go 1.13

require (
	haormj.xyz/go/dispatcher v0.0.1 // indirect
)

replace haormj.xyz/go/dispatcher v0.0.1 => code.haormj.xyz/go/dispatcher v0.0.1

优点: golang 原生解决方案
缺点: 需要使用者手动配置(当然也可以通过脚本生成)

方案二

配置GOPROXY透明完成haormj.xyzcode.haormj.xyz的切换

  1. 目前 goproxy 的原理就是通过go mod download实现下载
  2. 为了完成透明路径切换,需要完成一下内容
    • 将请求的路径 haormj.xyz/go/dispatcher替换为 code.haormj.xyz/go/dispatcher
    • go mod download后的路径code.haormj.xyz/go/dispatcher替换为haormj.xyz/go/dispatcher
    • 将对应的 zip 文件解压后重新按照haormj.xyz/go/dispatcher压缩
    • 替换对应mod文件中的内容

优点: 对使用者透明,只需配置GOPROXY即可
缺点: 代理出现问题,会导致无法使用 go module

support /index

There's a desire for people to run private module indexes and sumdb without relying on google's pkgsite. However, similar projects like athens do not support the index feed needed to maintain these. It would be great if goproxy added support for /index and /latest. These are used by pkgsite to find new modules and regularly update the pkgsite database.

Ref:
https://sum.golang.org/latest
https://index.golang.org/index

Using cacher.Disk

What is the value of Root supposed/is intended to be when creating cacher.Disk?
It is commented as 'Root is the root of the caches.'

gp := goproxy.New()
gp.Cacher = &cacher.Disk{Root: "?"}

Cache

When using this proxy shouldn't any mods that are updated through it be pulled down and cached?

导入出错

GOPROXY=http://localhost:8080 go get github.com/siddontang/go-mysql/mysql


2021/05/20 17:57:21 github.com@latest: invalid github.com import path "github.com"
2021/05/20 17:57:22 github.com/siddontang@latest: invalid github.com import path "github.com/siddontang"
2021/05/20 18:00:09 github.com/siddontang/go-mysql/mysql@latest: git fetch -f origin refs/heads/:refs/heads/ refs/tags/:refs/tags/ in /Users/jake/go/pkg/mod/cache/vcs/92894505ca13a7c5b28497893ecf5a15e514a6846dce0982e06fd86323d1c118: exit status 128:
fatal: unable to access 'https://github.com/siddontang/go-mysql/': Failed to connect to github.com port 443: Operation timed out

where is cache files

this is my code:

func main() {
	g := goproxy.New()
	g.Cacher = &cacher.Disk{Root: "/opt/goproxy/cache"}
	g.GoBinEnv = append(
		os.Environ(),
		"GOPROXY=https://goproxy.cn,direct",
	)
	g.ProxiedSUMDBs = []string{"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org"}
	err := http.ListenAndServe("0.0.0.0:8080", g)
	if err != nil {
		fmt.Println(err)
	}
}

the proxy is working fine, but I can't found any cache file in /opt/goproxy/cache. is this expected behavior? where should I find the cached files?

goproxy logs:

systemd[1]: Started Goproxy.
goproxy[2914]: 2021/02/19 18:44:09 github.com@latest: invalid github.com import path "github.com"
goproxy[2914]: 2021/02/19 18:44:09 github.com/goproxy@latest: invalid github.com import path "github.com/goproxy"
goproxy[2914]: 2021/02/19 18:50:27 github.com@latest: invalid github.com import path "github.com"
goproxy[2914]: 2021/02/19 18:50:27 github.com/goproxy@latest: invalid github.com import path "github.com/goproxy"

thanks for your work.

server panic

sometimes the server log a panic:

http: panic serving 127.0.0.1:26140: runtime error: invalid memory address or nil pointer dereference
goroutine 55 [running]:
net/http.(*conn).serve.func1()
        /root/.gobrew/current/go/src/net/http/server.go:1850 +0xbf
panic({0x813680, 0xbae0d0})
        /root/.gobrew/current/go/src/runtime/panic.go:890 +0x262
log.(*Logger).Output(0xc0001620f0, 0x2?, {0xc0002440c0, 0x54})
        /root/.gobrew/current/go/src/log/log.go:198 +0x356
github.com/goproxy/goproxy.(*Goproxy).logErrorf(0xc0001a4000, {0x884d63?, 0xc00021a300?}, {0xc0001419d8?, 0xc000212300?, 0xc0002161e0?})
        /root/go/pkg/mod/github.com/goproxy/[email protected]/goproxy.go:734 +0xac
github.com/goproxy/goproxy.(*Goproxy).ServeHTTP(0xc0001a4000, {0x9358a0?, 0xc000220380}, 0xc00023a400)
        /root/go/pkg/mod/github.com/goproxy/[email protected]/goproxy.go:560 +0x1b66
net/http.serverHandler.ServeHTTP({0xc000214330?}, {0x9358a0, 0xc000220380}, 0xc00023a400)
        /root/.gobrew/current/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0002420a0, {0x935d60, 0xc00011b890})
        /root/.gobrew/current/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
        /root/.gobrew/current/go/src/net/http/server.go:3102 +0x4db

what is the cause? can it be ignored?

无法拉取gitlab中的私有包

线上测试出现 go mod download: xx.xx.com/gitlab/xx/[email protected]: invalid version: unknown revision v0.0.1

下面是内部代理源码

func main() {

	err := http.ListenAndServe(":"+port, &goproxy.Goproxy{
		GoBinEnv: append(
			os.Environ(),
			"GOPROXY=https://goproxy.cn,direct", // 使用 Goproxy.cn 作为上游代理
			"GOPRIVATE=xx.xx.com/gitlab",     // 解决私有模块的拉取问题(比如可以配置成公司内部的代码源)
		),
		ProxiedSUMDBs: []string{
			"sum.golang.org https://goproxy.cn/sumdb/sum.golang.org", // 代理默认的校验和数据库
		},
	})
	if err != nil {
		log.Println(err)
		return
	}
}

拉取私有包的服务的ENV

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="http://自建代理ip:port,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.15"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2783035286=/tmp/go-build -gno-record-gcc-switches"

goproxy redirect http proxy to transparent proxy cause some http quest 400 error

basic network
v2raya basic proxy mode, socks5 proxy port : 20170 , http proxy port :20171
goroxy command line : ./proxy sps --redir -p :8080 -P socks5://127.0.0.1:20170
iptables redirect the traffic based on dest ip address
ipv4/ipv6 dual stack

goproxy version: free_13.0

400 error request example:
http://ds.v6ns.vm3.test-ipv6.com/ip/?callback=_jqjsp&testdomain=test-ipv6.com&testname=test_v6ns

linux-router->root:~# curl -v "http://ds.v6ns.vm3.test-ipv6.com/ip/?callback=_jqjsp&testdomain=test-ipv6.com&testname=test_v6ns"

  • Trying 2001:470:1:18::115:80...
  • Connected to ds.v6ns.vm3.test-ipv6.com (2001:470:1:18::115) port 80 (#0)

GET /ip/?callback=_jqjsp&testdomain=test-ipv6.com&testname=test_v6ns HTTP/1.1
Host: ds.v6ns.vm3.test-ipv6.com
User-Agent: curl/7.81.0
Accept: /

  • Mark bundle as not supporting multiuse
    < HTTP/1.1 400 Bad Request
    < Connection: close
    < Proxy-Connection: close
    < Content-Length: 0
    <
  • Closing connection 0

isseue detail:
1 when goproxy redirect http proxy 20171 and using iptable , it get 400 error
2 when goproxy redirect socks5 proxy 20170 and using iptables , it's ok
3 when using the http proxy in broswer instead of using iptables , it's ok

is there a changelog?

I'm using 0.2.2 version, I want to upgrade it to 0.13, but I don't know what differences are between the two version.
I couldn't found a full log from 0.2 to 0.13.

Could someone describe the differences roughly please ?

自建goproxy,私有包拉取不了

具体问题描述:

  1. 执行 go get 私有包报错
go: downloading gitlab.private.com/group/eframe v0.0.0-20220313171137-8002bdaf0155
go get gitlab.private.com/group/eframe@latest: gitlab.private.com/group/[email protected]: verifying module: gitlab.private.com/group/[email protected]: reading https://goproxy.cn/sumdb/sum.golang.org/lookup/gitlab.private.com/group/[email protected]: 404 Not Found
      server response:
      not found: gitlab.private.com/group/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/8c183c5c7094a475fac32b3c6967730307b328c913f0052b5fbe1f1be7874107: exit status 128:
              fatal: could not read Username for 'https://gitlab.private.com': terminal prompts disabled

goproxy 结构:

goproxy.Goproxy{
	GoBinEnv: append(os.Environ(),
		"GOPROXY=https://goproxy.cn,direct",
		"GOSUMDB=sum.golang.google.cn",
		"GOPRIVATE=gitlab.private.com",
	),
	ProxiedSUMDBs: "sum.golang.org https://goproxy.cn/sumdb/sum.golang.org",
}

在容器内执行 git ls-remote -q http://gitlab.private.com/group/eframe.git 是可以获取到的。
容器内执行 GOPRIVATE=gitlab.private.com go get gitlab.private.com/group/eframe@latest 也是正常的。

疑问点是:为啥会去 goproxy.cn/sumdb 读,已经配置 GOPRIVATE 了(感觉是代码中的 GoBinEnv 中的 GOPRIVATE 没有生效)

可以使用 goproxy 解决私有 GitLab 仓库问题吗?

公司的项目用到了内部 GitLab 的 PKG,导致 docker build 会拉不到,所以我想着使用该项目搭建一个公司的 goproxy,不知道能不能解决私有仓库问题。
有两个解决方案:

  1. 配置 .netrc
  2. 配置 ssh key + git config url."[email protected]".insteadOf "git.private.com"

但是不知道这两套方案是否能够解决私有仓库问题,或者还有其他更好的方案吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.