Git Product home page Git Product logo

goproxy.cn'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.cn's People

Contributors

aofei avatar dependabot[bot] avatar jonyhy96 avatar testwill 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  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

goproxy.cn's Issues

go get -u golang.org/x/*

$ go get -u golang.org/x/lint/golint
package golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

env 如下
set GOPATH=E:\WorkSpace
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=c:\go

这个该怎么用呢?

不工作在mod模式下是无法使用的吗?

已经设置了 GOPROXY 环境变量
尝试 go get golang.org/x/tools/gopls
返回超时错误

C:\Users\linho>echo %goproxy%
https://goproxy.cn

C:\Users\linho>go get golang.org/x/tools/gopls
package golang.org/x/tools/gopls: unrecognized import path "golang.org/x/tools/gopls"  
(https fetch: Get https://golang.org/x/tools/gopls?go-get=1: dial tcp 172.217.24.81:443: connectex:   
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

C:\Users\linho>curl https://goproxy.cn/golang.org/x/tools/gopls/
Not Found
C:\Users\linho>curl https://goproxy.cn/golang.org/x/tools/gopls/@latest
{"Version":"v0.1.3","Time":"2019-07-10T16:59:51Z"}
C:\Users\linho>

go get with custom package name 404

GOPROXY=https://goproxy.cn/ GO111MODULE=on go get kubesphere.io/kubesphere@cda4f4f05ae1d5c653e7158b8de0164f92341e5c
go: finding kubesphere.io/kubesphere v0.0.0-20190726052749-cda4f4f05ae1
go: finding github.com/onsi/ginkgo v1.8.0
go: kubesphere.io/[email protected]: unexpected status (https://goproxy.cn/kubesphere.io/kubesphere/@v/v0.0.0-20190726052749-cda4f4f05ae1.info): 404 Not Found
go: error loading module requirements

go-redis 404

package github.com/go-redis/redis return 'not found'

not a valid zip file

/go/pkg/mod/alilog/log.go:12:2: unknown import path "github.com/aliyun/aliyun-log-go-sdk": zip: not a valid zip file
/go/pkg/mod/helper/mac_ip.go:6:2: unknown import path "github.com/asaskevich/govalidator": zip: not a valid zip file
/go/pkg/mod/paginate.pb.go:16:8: unknown import path "github.com/golang/protobuf/proto": zip: not a valid zip file
/go/pkg/mod/mysql.go:6:2: unknown import path "github.com/jinzhu/gorm": zip: not a valid zip file
/go/pkg/mod/mysql.go:7:2: unknown import path "github.com/jinzhu/gorm/dialects/mysql": zip: not a valid zip file

429 Too Many Requests

when i use goproxy.cn I got this

o: github.com/prometheus/[email protected]: unexpected status (https://goproxy.cn/github.com/prometheus/client_model/@v/v0.0.0-20171117100541-99fa1f4be8e5.info): 429 Too Many Requests
go: gopkg.in/[email protected]: unexpected status (https://goproxy.cn/gopkg.in/tomb.v1/@v/v1.0.0-20141024135613-dd632973f1e7.info): 429 Too Many Requests
go: golang.org/x/[email protected]: unexpected status (https://goproxy.cn/golang.org/x/sys/@v/v0.0.0-20180909124046-d0be0721c37e.info): 429 Too Many Requests

http 和 https 的区别

一次我把环境变量输错了 export GOPROXY=http://goproxy.cn 然后就会出现类似下面的错误

go: golang.org/x/[email protected]: Get http://goproxy.cn/golang.org/x/sys/@v/v0.0.0-20181031143558-9b800f95dbbc.info: read tcp 10.23.66.xx:63782->34.95.75.160:80: read: connection reset by peer

但是换回 https 就是正常的。

想知道这个是什么原因。如果有大佬回复,感激不尽呐。

版本号疑问

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

What did you do?

为什么下载的版本都带版本号,
image

还要一个似乎go编译喜欢在以下位置去索引包

/usr/local/go/src/

/users/local/go/src/

而go get似乎下载在/users/local/go/phg/mod/ 是我环境变量设置问题么。。。

What is the behavior of the bug?

Do you have any guesses?

能去掉版本号吗。。。

请教下go mod 多目录分模块的问题

通常这样新建一个模块并且发布:

go mod init github.com/username/modulename
git tag v1.0.0
git push origin v1.0.0
go get github.com/username/[email protected]

上面这样以根目录发布一个模块, 没有问题.

问题是同一个仓库下多个目录分模块:

github.com/username/modulename/moda
github.com/username/modulename/modb
github.com/username/modulename/modc

这样分 moda/modb/modc 模块, 应该如果发布各自的版本?

not work

[root@k8s-m1 go]# export GOPROXY=https://goproxy.cn
[root@k8s-m1 go]# go get -u github.com/prometheus/common/log
package golang.org/x/sys/unix: unrecognized import path "golang.org/x/sys/unix" (https fetch: Get https://golang.org/x/sys/unix?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
[root@k8s-m1 go]# env | grep -i proxy
GOPROXY=https://goproxy.cn

k8s模块拉取报错

go version:1.12.7
k8s version: 1.13.7
下载k8s.io/kubernetes v1.15.2这个模块时报错
go: k8s.io/[email protected]: unexpected EOF

D:\k8s\kubernetes-1.13.7>go mod tidy
go: finding k8s.io/apimachinery latest
go: finding k8s.io/sample-cli-plugin latest
go: finding k8s.io/apiserver latest
go: finding k8s.io/apiextensions-apiserver latest
go: finding k8s.io/sample-controller latest
go: finding k8s.io/cloud-provider latest
go: finding golang.org/x/crypto latest
go: finding k8s.io/gengo latest
go: finding k8s.io/sample-apiserver latest
go: finding k8s.io/metrics latest
go: finding k8s.io/api latest
go: finding k8s.io/kube-aggregator latest
go: finding k8s.io/kube-openapi latest
go: finding k8s.io/code-generator latest
go: finding github.com/heketi/tests latest
go: finding k8s.io/csi-api latest
go: finding k8s.io/cli-runtime latest
go: finding gopkg.in/yaml.v1 latest
go: finding golang.org/x/time latest
go: finding k8s.io/kube-proxy latest
go: finding cloud.google.com/go/compute/metadata latest
go: finding k8s.io/kube-controller-manager latest
go: finding k8s.io/utils latest
go: finding github.com/golangplus/testing latest
go: finding k8s.io/cluster-bootstrap latest
go: finding k8s.io/kube-scheduler latest
go: finding github.com/heketi/rest latest
go: finding golang.org/x/oauth2 latest
go: finding golang.org/x/sync latest
go: finding k8s.io/kubelet latest
go: finding google.golang.org/genproto latest
go: finding github.com/auth0/go-jwt-middleware latest
go: finding github.com/smartystreets/goconvey latest
go: finding github.com/containerd/typeurl latest
go: finding github.com/xlab/handysort latest
go: finding gonum.org/v1/netlib latest
go: k8s.io/[email protected]: unexpected EOF
go: error loading module requirement

cannot get with the version at windows


C:\Users\guanzhang>go get -u github.com/parnurzeal/gorequest@develop
go: finding github.com/parnurzeal/gorequest develop
go: finding github.com/parnurzeal develop
go: finding github.com develop
go get github.com/parnurzeal/gorequest@develop: Get https://goproxy.cn/github.co
m/parnurzeal/gorequest/@v/develop.info: dial tcp 35.186.235.12:443: connectex: A
 connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host
has failed to respond.

if I use annother proxy could succeed

C:\Users\guanzhang>set GOPROXY=https://athens.azurefd.net

C:\Users\guanzhang>go get -u github.com/parnurzeal/gorequest@develop
go: finding github.com/parnurzeal/gorequest develop
go: downloading github.com/parnurzeal/gorequest v0.2.15-0.20190114090633-b060445
4e3c3
go: extracting github.com/parnurzeal/gorequest v0.2.15-0.20190114090633-b0604454
e3c3

C:\Users\guanzhang>

fatal: unable to access 'https://go.googlesource.com/tools/'

更新到 go1.13 ,并使用 go env -w GOPROXY=https://goproxy.cn,direct 配置了 GOPROXY 变量后。

我在命令行为 VSCode 的 Go 扩展安装 tools

go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/go-delve/delve/cmd/dlv
go get -u -v github.com/stamblerre/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/sqs/goreturns
go get -u -v golang.org/x/lint/golint
go get -u -v github.com/cweill/gotests/...
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/josharian/impl
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/godoctor/godoctor

有若干模块,全部都是由于同样的原因安装失败。

git pull --ff-only
fatal: unable to access 'https://go.googlesource.com/tools/': Failed to connect to go.googlesource.com port 443: 连接超时

请问,这是什么原因呢?

请教一个问题 使用god+goproxy编译已有项目时经常会遇到echo无法正常驱动

go: finding github.com/labstack/echo v0.0.0-20190621131255-858270f6f5e4
go: github.com/labstack/[email protected]: unexpected status (https://goproxy.cn/github.com/labstack/echo/@v/v0.0.0-20190621131255-858270f6f5e4.info): 404 Not Found
go: error loading module requirements

请教一个问题 使用god+goproxy编译已有项目时经常会遇到echo无法正常驱动,但是通过本地包replace替换之后,再次取消replace ,又可以正常工作了

checksum mismatch

verifying github.com/kataras/iris/[email protected]/go.mod: checksum mismatch
downloaded: h1:G7mAYYxgmS0lVkHyy2hEOLQCFB0DlQFTMLWggykrydY=
go.sum: h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U=

since 2019-11-18 22:33:18

问题:使用goproxy引用包404

你确定我们的常见问题页面中没有你想要咨询的问题吗?

当你执行 go version 命令后的输出结果是什么?

$ go version


当你执行 go env 命令后的输出结果是什么?

go env 的输出结果
$ go env

你做了什么?

是否能帮忙看看这是什么问题?(使用goproxy引用包404)[https://github.com/zouyx/agollo/issues/84]

我访问的goproxy.cn的ip是:47.246.16.225。我是没问题的,这个issue里的兄弟是不行的

>ping goproxy.cn

正在 Ping qiniuopencdn.jomodns.com [47.246.16.225] 具有 32 字节的数据:
来自 47.246.16.225 的回复: 字节=32 时间=20ms TTL=111
来自 47.246.16.225 的回复: 字节=32 时间=12ms TTL=111

你期望看到的结果是什么?

你实际看到的结果是什么?

vscode 自动更新 golang.org/x/tools/gopls 失败

go env

GO111MODULE=""             
GOARCH="amd64"      
GOBIN=""      
GOCACHE="/Users/xx/Library/Caches/go-build"
GOENV="/Users/xx/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/xx/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xh/n51j5hsx5vn2gyh8g0sk3kd00000gn/T/go-build637758764=/tmp/go-build -gno-record-gcc-switches -fno-common"
 

vscode

go.toolsGopath setting is not set. Using GOPATH /Users/xx/go
Installing 1 tool at /Users/xx/go/bin in module mode.
  gopls

Installing golang.org/x/tools/gopls FAILED

1 tools failed to install.

gopls:
Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/gopls
go: finding golang.org/x/tools/gopls v0.2.0
go: downloading golang.org/x/tools/gopls v0.2.0
go: finding golang.org/x/tools latest
go: downloading golang.org/x/tools v0.0.0-20191112005509-a3f652f18032
go: extracting golang.org/x/tools/gopls v0.2.0
go: extracting golang.org/x/tools v0.0.0-20191112005509-a3f652f18032
go get golang.org/x/tools/gopls: module golang.org: reading https://goproxy.cn/golang.org/@v/list: 502 Bad Gateway
go: finding golang.org/x/tools/gopls v0.2.0
go: downloading golang.org/x/tools/gopls v0.2.0
go: finding golang.org/x/tools latest
go: downloading golang.org/x/tools v0.0.0-20191112005509-a3f652f18032
go: extracting golang.org/x/tools/gopls v0.2.0
go: extracting golang.org/x/tools v0.0.0-20191112005509-a3f652f18032
go get golang.org/x/tools/gopls: module golang.org: reading https://goproxy.cn/golang.org/@v/list: 502 Bad Gateway

package golang.org/x/net/publicsuffix: unrecognized import path

windows下已经加入了环境变量,但还是go get失败

 go get -u github.com/winterssy/music-get
package golang.org/x/net/publicsuffix: unrecognized import path "golang.org/x/net/publicsuffix" (https fetch: Get https://golang.org/x/net/publicsuffix?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
package golang.org/x/crypto/ssh/terminal: unrecognized import path "golang.org/x/crypto/ssh/terminal" (https fetch: Get https://golang.org/x/crypto/ssh/terminal?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

$ go version
go version go1.11 windows/amd64

cannot download modules under google.golang.org

It occured when I use go mod tidy for module github.com/go-sql-driver/mysql:

my-test-package imports
        github.com/go-sql-driver/mysql imports
        google.golang.org/appengine/cloudsql: cannot find module provid
ing package google.golang.org/appengine/cloudsql

After I enabled the global vpn proxy, that module can be downloaded successfully, so I guass there was something wrong with goproxy.cn

请问这里的代理包多久更新一次

go.mod:8: require github.com/casbin/gorm-adapter: reading https://goproxy.cn/github.com/casbin/gorm-adapter/@v/v2.0.0.info: 404 Not Found

有好一些包获取到的都不是最新版本的,用latest标记获取到的也是一些较老的包

proxy returned info for version XXX instead of requested version

go mod download
go: finding github.com/prometheus/client_model v0.0.0-20190220174349-fd36f4220a90
github.com/prometheus/[email protected]: proxy returned info for version v0.0.0-20190129233127-fd36f4220a90 instead of requested version

===========================
使用 goproxy.cn 下载会出现上述错误,使用 direct 模式或阿里云镜像则下载正常

go version: 1.13

unrecognized import path "golang.org/x/tools/go/ast/astutil" (https fetch: Get https://golang.org/x/tools/go/ast/astutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

hi :
我go get 的时候发现超时,已经持续两天了,想知道是我网络的问题还是服务端的问题?�
深圳电信。。。

$ go get github.com/google/wire/cmd/wire
package golang.org/x/tools/go/ast/astutil: unrecognized import path "golang.org/x/tools/go/ast/astutil" (https fetch: Get https://golang.org/x/tools/go/ast/astutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
package golang.org/x/tools/go/packages: unrecognized import path "golang.org/x/tools/go/packages" (https fetch: Get https://golang.org/x/tools/go/packages?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
package golang.org/x/tools/go/types/typeutil: unrecognized import path "golang.org/x/tools/go/types/typeutil" (https fetch: Get https://golang.org/x/tools/go/types/typeutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

下面是我的go env,系统是macOS

$ go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hyk/Library/Caches/go-build"
GOENV="/Users/hyk/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/hyk/Documents/code/gopath"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/c8/wwjlz_7n5kxbdfsgjxj09kx00000gn/T/go-build636543512=/tmp/go-build -gno-record-gcc-switches -fno-common"

GOPROXY="https://goproxy.cn,direct"
我试过GOPROXY="https://goproxy.cn" 也是一样的超时

go version go1.13 darwin/amd64

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.