我怎样才能获得Go的远程包?

时间:2017-08-16 05:01:48

标签: git go

将gin包导入Go项目时遇到问题。

代码:

package main

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

func main() {
    r := gin.Default()
    r.GET("/ping", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "pong",
        })
    })
    r.Run() // listen and serve on 0.0.0.0:8080
}

我正在使用go get命令安装gin包,但它不起作用。

C:\Users\YShipovalov\Desktop\Golang\helloworld>go get -v github.com/gin-gonic/gi
n
Fetching https://gopkg.in/go-playground/validator.v8?go-get=1
https fetch failed: Get https://gopkg.in/go-playground/validator.v8?go-get=1: di
al tcp 45.33.37.13:443: connectex: No connection could be made because the targe
t machine actively refused it.
package gopkg.in/go-playground/validator.v8: unrecognized import path "gopkg.in/
go-playground/validator.v8" (https fetch: Get https://gopkg.in/go-playground/val
idator.v8?go-get=1: dial tcp 45.33.37.13:443: connectex: No connection could be
made because the target machine actively refused it.)
Fetching https://gopkg.in/yaml.v2?go-get=1
https fetch failed: Get https://gopkg.in/yaml.v2?go-get=1: dial tcp 45.33.37.13:
443: connectex: No connection could be made because the target machine actively
refused it.
package gopkg.in/yaml.v2: unrecognized import path "gopkg.in/yaml.v2" (https fet
ch: Get https://gopkg.in/yaml.v2?go-get=1: dial tcp 45.33.37.13:443: connectex:
No connection could be made because the target machine actively refused it.)

我在git中设置了代理设置,这可能是个问题吗?

2 个答案:

答案 0 :(得分:2)

尝试:

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:14:59) 
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
numpy 1.13.1

0.06289491400821134
0.05558946297969669
0.0670205659698695
0.057950171001721174

那将导入该框架的固定版本。

例如参见" Build RESTful API service in golang using gin-gonic framework"

但如果你有代理问题,那导入也应该失败 正如在" Building Go Web Applications and Microservices Using Gin"中所见,go Python 3.5.3 |Continuum Analytics, Inc.| (default, Mar 6 2017, 12:15:08) IPython 5.3.0 -- An enhanced Interactive Python. numpy 1.11.3 0.06345970398979262 0.05561513203429058 0.07043616304872558 0.057934076990932226 也应该有用。

尝试删除Python 3.6.2 (default, Jul 19 2017, 11:01:41) IPython 6.1.0 numpy 1.12.0 0.39130385394673795 0.24979593697935343 0.42852322908584028 0.28863119706511497 中的代理指令。

尝试改为设置0.158213707338 0.149441164907 0.365552662475 0.128456460354 (确保在两种情况下都使用http网址作为变量,正如我在&#34中所说明的那样; this answer")

答案 1 :(得分:0)

修正版并不重要! 的: $ go get github.com/gin-gonic/gin 应该正常工作!! 固定版本适用于您需要特定版本的时间!