[Windows]go get github.com/gin-gonic/gin failed with connectex: A connection attempt failed

1.1k Views Asked by At

Code:

package main

import "github.com/gin-gonic/gin"

func main() {
    r := gin.Default()

    r.Handle("GET", "/ping", func(context *gin.Context) {
        context.JSON(200, gin.H{
            "message": "pong",
        })
    })

    r.Run() 
}

Error:

C:\Users\hxia\go\Gin>go run main.go
main.go:3:8: no required module provides package github.com/gin-gonic/gin; to add it:
        go get github.com/gin-gonic/gin

C:\Users\hxia\go\Gin>go get github.com/gin-gonic/gin
go get: module github.com/gin-gonic/gin: Get "https://goproxy.cn/github.com/gin-gonic/gin/@v/list": dial tcp 163.181.42.206: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 GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\hxia\AppData\Local\go-build
set GOENV=C:\Users\hxia\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\hxia\go\pkg\mod
set GONOPROXY=.gitlab.com,.gitee.com
set GONOSUMDB=.gitlab.com,.gitee.com
set GOOS=windows
set GOPATH=C:\Users\hxia\go
set GOPRIVATE=.gitlab.com,.gitee.com
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Users\hxia\@hxia\GoLang
set GOSUMDB=sum.golang.google.cn
set GOTMPDIR=
set GOTOOLDIR=C:\Users\hxia\@hxia\GoLang\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.2
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\hxia\go\Gin\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\hxia\AppData\Local\Temp\go-build2669851048=/tmp/go-build -gno-record-gcc-switches

Description:

With the go get to download the Gin module, it shows failed with a connection error, check the env it seems configure right with:

set GO111MODULE=on
set GOPROXY=https://goproxy.cn,direct

Change the GOPROXY to https://goproxy.io.direct it failed too.

I have configured a http_proxy in visual studio, then suspend whether is something wrong with the proxy, so remove the proxy, change the proxy from HTTP to HTTPS, all failed.

could any experts can point the issue out, how can I fix the issue? thanks so much!!

0

There are 0 best solutions below