goproxy / goproxy.cn

The most trusted Go module proxy in China.
https://goproxy.cn
MIT License
6.83k stars 394 forks source link

问题:设置代理后依然无法下载到golang.org/x/ 相关包 #54

Closed lovingyu closed 4 years ago

lovingyu commented 4 years ago

以下环境相关信息:

Ubuntu 18.04 x64

$ go version
 go version go1.13.5 linux/amd64
$ dep version
dep:
 version     : v0.5.4
 build date  : 
 git hash    : 
 go version  : go1.13.5
 go compiler : gc
 platform    : linux/amd64
 features    : ImportDuringSolve=false

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

go env 的输出结果
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/wilson/goProject/bin"
GOCACHE="/home/wilson/.cache/go-build"
GOENV="/home/wilson/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/wilson/goProject"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build438782863=/tmp/go-build -gno-record-gcc-switches"

设置代理目标

设置代理,主要是为了本地编译telegraf源码,下面是telegraf文件内的Gopkg.toml文件内容 https://github.com/influxdata/telegraf

Gopkg.toml 的文件内容
[[constraint]]
  name = "collectd.org"
  version = "0.3.0"

[[constraint]]
  name = "github.com/aerospike/aerospike-client-go"
  version = "<=1.27.0"

[[constraint]]
  name = "github.com/amir/raidman"
  branch = "master"

[[constraint]]
  name = "github.com/apache/thrift"
  branch = "master"

[[constraint]]
  name = "github.com/aws/aws-sdk-go"
  version = "1.19.41"

[[constraint]]
  name = "github.com/couchbase/go-couchbase"
  branch = "master"

[[constraint]]
  name = "github.com/dgrijalva/jwt-go"
  version = "3.2.0"

[[constraint]]
  name = "github.com/docker/docker"
  revision = "ed7b6428c133e7c59404251a09b7d6b02fa83cc2" # v18.05.0-ce

[[override]]
  name = "github.com/docker/distribution"
  revision = "edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c" # v18.05.0-ce

[[constraint]]
  name = "github.com/eclipse/paho.mqtt.golang"
  version = "1"

[[constraint]]
  name = "github.com/go-sql-driver/mysql"
  version = "1.4.0"

[[constraint]]
  name = "github.com/gobwas/glob"
  version = "0.2.3"

[[constraint]]
  name = "github.com/golang/protobuf"
  version = "1.1.0"

[[constraint]]
  name = "github.com/google/go-cmp"
  version = "0.2.0"

[[constraint]]
  name = "github.com/gorilla/mux"
  version = "1.6.2"

[[constraint]]
  name = "github.com/go-redis/redis"
  version = "6.12.0"

[[constraint]]
  name = "github.com/hashicorp/consul"
  version = "1.1.0"

[[constraint]]
  name = "github.com/influxdata/go-syslog"
  version = "2.0.0"

[[constraint]]
  name = "github.com/influxdata/tail"
  branch = "master"

[[constraint]]
  name = "github.com/influxdata/toml"
  branch = "telegraf"

[[constraint]]
  name = "github.com/influxdata/wlog"
  branch = "master"

[[constraint]]
  name = "github.com/jackc/pgx"
  version = "3.4.0"

[[constraint]]
  name = "github.com/kardianos/service"
  branch = "master"

[[constraint]]
  name = "github.com/kballard/go-shellquote"
  branch = "master"

[[constraint]]
  name = "github.com/matttproud/golang_protobuf_extensions"
  version = "1.0.1"

[[constraint]]
  name = "github.com/Microsoft/ApplicationInsights-Go"
  version = "0.4.2"

[[constraint]]
  name = "github.com/miekg/dns"
  version = "1.0.10"

[[constraint]]
  name = "github.com/multiplay/go-ts3"
  version = "1.0.0"

[[constraint]]
  name = "github.com/nats-io/gnatsd"
  version = "1.1.0"

[[constraint]]
  name = "github.com/nats-io/go-nats"
  version = "1.5.0"

[[constraint]]
  name = "github.com/nsqio/go-nsq"
  version = "1.0.7"

[[constraint]]
  name = "github.com/openzipkin/zipkin-go-opentracing"
  version = "0.3.4"

[[constraint]]
  name = "github.com/prometheus/client_golang"
  version = "0.9.2"

[[constraint]]
  name = "github.com/prometheus/client_model"
  branch = "master"

[[constraint]]
  name = "github.com/prometheus/common"
  branch = "master"

[[constraint]]
  name = "github.com/gofrs/uuid"
  version = "2.0.0"

[[constraint]]
  name = "github.com/shirou/gopsutil"
  version = "2.19.7"

[[constraint]]
  name = "github.com/Shopify/sarama"
  version = "1.24.0"

[[constraint]]
  name = "github.com/soniah/gosnmp"
  version = "1.22.0"

[[constraint]]
  name = "github.com/StackExchange/wmi"
  version = "1.0.0"

[[constraint]]
  name = "github.com/streadway/amqp"
  branch = "master"

[[constraint]]
  name = "github.com/stretchr/testify"
  version = "1.2.2"

[[constraint]]
  name = "github.com/tidwall/gjson"
  version = "1.1.1"

[[constraint]]
  name = "github.com/vjeantet/grok"
  version = "1.0.0"

[[constraint]]
  name = "github.com/wvanbergen/kafka"
  branch = "master"

[[constraint]]
  name = "github.com/denisenkom/go-mssqldb"
  branch = "master"

[[constraint]]
  name = "golang.org/x/net"
  branch = "master"
  source = "https://github.com/golang/net.git"

[[constraint]]
  name = "golang.org/x/sys"
  branch = "master"
  source = "https://github.com/golang/sys.git"

[[constraint]]
  name = "google.golang.org/grpc"
  version = "1.12.2"

[[constraint]]
  name = "gopkg.in/gorethink/gorethink.v3"
  version = "3.0.5"

[[constraint]]
  name = "gopkg.in/mgo.v2"
  branch = "v2"

[[constraint]]
  name = "gopkg.in/olivere/elastic.v5"
  version = "^5.0.69"

[[constraint]]
  name = "gopkg.in/yaml.v2"
  version = "^2.2.1"

[[override]]
  source = "https://github.com/fsnotify/fsnotify/archive/v1.4.7.tar.gz"
  name = "gopkg.in/fsnotify.v1"

[[constraint]]
  name = "github.com/mdlayher/apcupsd"
  revision = "eb3dd99a75fe58389e357b732691320dcf706b5f"

[[constraint]]
  branch = "master"
  name = "google.golang.org/genproto"

[[constraint]]
  name = "github.com/vmware/govmomi"
  version = "0.19.0"

[[constraint]]
  name = "github.com/Azure/go-autorest"
  version = "^13.0.0"

[[constraint]]
  name = "github.com/Azure/azure-storage-queue-go"
  version = "0.2.0"

[[constraint]]
  branch = "master"
  name = "golang.org/x/oauth2"
  source = "https://github.com/golang/oauth2.git"

[[constraint]]
  branch = "master"
  name = "github.com/docker/libnetwork"

[[override]]
  name = "github.com/vishvananda/netlink"
  revision = "b2de5d10e38ecce8607e6b438b6d174f389a004e"

[[constraint]]
  name = "github.com/wavefronthq/wavefront-sdk-go"
  version = "^0.9.1"

[[constraint]]
  name = "github.com/karrick/godirwalk"
  version = "1.10"

[[override]]
  name = "github.com/harlow/kinesis-consumer"
  branch = "master"

[[constraint]]
  branch = "master"
  name = "github.com/kubernetes/apimachinery"

[[constraint]]
  name = "github.com/go-logfmt/logfmt"
  version = "0.4.0"

[[constraint]]
  branch = "master"
  name = "github.com/ghodss/yaml"

[[override]]
  name = "golang.org/x/crypto"
  source = "https://github.com/golang/crypto.git"

[[override]]
  name = "golang.org/x/sync"
  source = "https://github.com/golang/sync.git"

[[override]]
  name = "golang.org/x/text"
  source = "https://github.com/golang/text.git"

[[constraint]]
  name = "github.com/google/go-github"
  version = "24.0.1"

[[constraint]]
  branch = "master"
  name = "github.com/openconfig/gnmi"

[[constraint]]
  branch = "master"
  name = "github.com/cisco-ie/nx-telemetry-proto"

[[constraint]]
  name = "gopkg.in/ldap.v3"
  version = "3.1.0"

[[constraint]]
  name = "github.com/safchain/ethtool"
  revision = "42ed695e3de80b9d695f280295fd7994639f209d"

[[override]]
  name = "github.com/satori/go.uuid"
  revision = "b2ce2384e17bbe0c6d34077efa39dbab3e09123b"

执行命令

在telegraf目录下,执行了以下命令:

$ go env -w GOPROXY=https://goproxy.cn,direct
$ export GO111MODULE=on 
$ dep ensure -v

返回结果是:

The following issues were found in Gopkg.toml:

  ✗ unable to deduce repository and source type for "golang.org/x/oauth2": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://golang.org/x/oauth2?go-get=1": Get http://golang.org/x/oauth2?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused
  ✗ unable to deduce repository and source type for "google.golang.org/grpc": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://google.golang.org/grpc?go-get=1": Get http://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused
  ✗ unable to deduce repository and source type for "golang.org/x/text": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://golang.org/x/text?go-get=1": Get http://golang.org/x/text?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused
  ✗ unable to deduce repository and source type for "google.golang.org/genproto": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://google.golang.org/genproto?go-get=1": Get http://google.golang.org/genproto?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused
  ✗ unable to deduce repository and source type for "golang.org/x/crypto": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://golang.org/x/crypto?go-get=1": Get http://golang.org/x/crypto?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused
  ✗ unable to deduce repository and source type for "golang.org/x/sys": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://golang.org/x/sys?go-get=1": Get http://golang.org/x/sys?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused
  ✗ unable to deduce repository and source type for "golang.org/x/sync": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://golang.org/x/sync?go-get=1": Get http://golang.org/x/sync?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused
  ✗ unable to deduce repository and source type for "golang.org/x/net": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://golang.org/x/net?go-get=1": Get http://golang.org/x/net?go-get=1: dial tcp 216.239.37.1:80: connect: connection refused

ProjectRoot name validation failed

代理无效,无法下载相关包。 求帮助,谢谢

aofei commented 4 years ago

你好,你的 dep ensure -v 说明你仍在使用 dep,此时 goproxy.cn 是无法帮助到你的。Go 模块代理是给 Go 模块用的,并不能用于诸如 dep 等其他依赖管理解决方案。

lovingyu commented 4 years ago

收到,谢谢。

aofei commented 4 years ago

由于此 Issue 中的问题已解决,所以我就关闭这个 Issue 了哈,如果还有其他问题欢迎随时提问。😊