dsc862009 2017-08-16 05:01
浏览 87

如何获得Go的远程软件包?

I have problem with importing gin package into my Go project.

Code:

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
}

I'm using go get command to install gin package, but it doesn't work.

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.)

I have set proxy settings in git,so can this be a problem?

  • 写回答

2条回答 默认 最新

  • dongtuo5611 2017-08-16 05:13
    关注

    Try with:

      go get gopkg.in/gin-gonic/gin.v1
    

    That will import a fixed version of that framework.

    See for instance "Build RESTful API service in golang using gin-gonic framework"

    But if you have proxy issue, that import should fail too.
    As seen in "Building Go Web Applications and Microservices Using Gin", go get -u github.com/gin-gonic/gin should work too.

    Try removing proxy directive in your .gitconfig.

    Try instead setting HTTP_PROXY/HTTPS_PROXY (make sure to use http url in both cases for the variables, as I illustrate in "this answer")

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能