go get golang.org被墙问题解决

今天在下载golang.org/x/image/tiff的时候出错

> go get -v golang.org/x/image/tiff
Fetching https://golang.org/x/image/tiff?go-get=1
https fetch failed: Get https://golang.org/x/image/tiff?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
package golang.org/x/image/tiff: unrecognized import path "golang.org/x/image/tiff" (https fetch: Get https://golang.org/x/image/tiff?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

网上看了一下,大致是由于墙的问题。

网上的方式大致有两种,一种是使用golang.org在github上的镜像,比如https://github.com/golang/image

在gopath目录下手动创建src/golang.org/x/, 然后直接使用git clone https://github.com/golang/image 到 src/golang.org/x/image目录

但是由于我最终希望下的是qor项目,它依赖非常多的golang.org/x/的项目,一个个这么做也是够累人的。

于是选择了第二个方法,设置proxy。

设置session的http_proxy

翻墙软件搭建在自己机器上, 使用端口61745, 先设置当前session使用的http_proxy

export http_proxy="http://127.0.0.1:61745" export https_proxy=$http_proxy

设置完成之后,但是还是出现问题:

go get -v golang.org/x/image/tiff
Fetching https://golang.org/x/image/tiff?go-get=1
Parsing meta tags from https://golang.org/x/image/tiff?go-get=1 (status code 200)
get "golang.org/x/image/tiff": found meta tag get.metaImport{Prefix:"golang.org/x/image", VCS:"git", RepoRoot:"https://go.googlesource.com/image"} at https://golang.org/x/image/tiff?go-get=1
get "golang.org/x/image/tiff": verifying non-authoritative meta tag
Fetching https://golang.org/x/image?go-get=1
Parsing meta tags from https://golang.org/x/image?go-get=1 (status code 200)
golang.org/x/image (download)
# cd .; git clone https://go.googlesource.com/image /Users/yejianfeng/Documents/gopath/src/golang.org/x/image
Cloning into '/Users/yejianfeng/Documents/gopath/src/golang.org/x/image'...
fatal: unable to access 'https://go.googlesource.com/image/': Failed to connect to go.googlesource.com port 443: Operation timed out
package golang.org/x/image/tiff: exit status 128

设置git的http_proxy

大致再搜了一下,是git的http_proxy没有设置好。

于是做了一下设置:

git config --global http.proxy http://127.0.0.1:61745

终于可以了

go get -v golang.org/x/image/tiff
Fetching https://golang.org/x/image/tiff?go-get=1
Parsing meta tags from https://golang.org/x/image/tiff?go-get=1 (status code 200)
get "golang.org/x/image/tiff": found meta tag get.metaImport{Prefix:"golang.org/x/image", VCS:"git", RepoRoot:"https://go.googlesource.com/image"} at https://golang.org/x/image/tiff?go-get=1
get "golang.org/x/image/tiff": verifying non-authoritative meta tag
Fetching https://golang.org/x/image?go-get=1
Parsing meta tags from https://golang.org/x/image?go-get=1 (status code 200)
golang.org/x/image (download)
golang.org/x/image/tiff/lzw
golang.org/x/image/tiff

也可以很方便使用 go get -u 来下载项目的依赖了。

取消

session的http_proxy是关闭session之后会取消的。

但是git的http.proxy这里是设置的全局的,我们下载完成之后,希望进行取消的话,执行操作:

git config --global --unset http.proxy

后记

据说现在有

参考文档

git 设置和取消代理

go get golang.org被墙问题解决的更多相关文章

  1. 解决 VS Code 中 golang.org 被墙导致的 Go 插件安装失败问题

    微软官方开发的 Go for Visual Studio Code 插件为 Go 语言 提供了丰富的支持.在 VS Code 中首次打开 Go 工作区后,VS Code 会自动检测当前开发环境为 Go ...

  2. Golang学习 - 学习资源列表

    Golang 学习资源: <Go 语言圣经(中文版)>  - 书籍 http://shinley.com/index.html <学习 Go 语言> - 书籍 http://w ...

  3. VS code golang 开发环境搭建

    安装go (1)下载go安装程序 下载地址:https://golang.org/dl/(墙内下载地址http://www.golangtc.com/download),如果是您的系统是windows ...

  4. Centos7安装golang

    标准官网:https://golang.org/ 需要墙 镜像官网:https://golang.google.cn/dl/ [国内推荐] 1.下载文件 # wget https://dl.googl ...

  5. Go语言开发第一个Hello,World

    在网上看到go语言的各种评价,也是闻名已久,但是没有自己实践过,也不知道它的好,它的坏,今天就来试试第一个小程序 第一步.如何下载 1)下载go安装程序 下载地址:https://golang.org ...

  6. Go语言开发环境配置

    一.我为什么要学习go语言 当今已经是移动和云计算时代,Go出现在了工业向云计算转型的时刻,简单.高效.内 置并发原语和现代的标准库让Go语言尤其适合云端软件开发(毕竟它就是为此而设计的).到2014 ...

  7. (转载)Go语言开发环境配置

    一.我为什么要学习go语言 当今已经是移动和云计算时代,Go出现在了工业向云计算转型的时刻,简单.高效.内 置并发原语和现代的标准库让Go语言尤其适合云端软件开发(毕竟它就是为此而设计的).到2014 ...

  8. Go语言开发环境搭建

    1.Go的安装 (1)下载go安装程序 下载地址:https://golang.org/dl/ (墙内下载地址http://www.golangtc.com/download),如果是您的系统是win ...

  9. go——搭建Win7下的Go开发环境

    1.首先需要下载下载go平台安装包 安装程序 下载地址:https://golang.org/dl/ (墙内下载地址http://www.golangtc.com/download),如果是您的系统是 ...

随机推荐

  1. javascript进阶

    BOM操作 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <met ...

  2. 模板——无旋Treap

    #include "bits/stdc++.h" using namespace std; inline int read(){ ,k=;char ch=getchar(); :, ...

  3. Java基础系列--基础排序算法

    原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9082138.html 一.概述 基础排序算法包括:桶排序.冒泡排序.选择排序.插入排序等 ...

  4. golang 中 string 转换 []byte 的一道笔试题

    背景 去面试的时候遇到一道和 string 相关的题目,记录一下用到的知识点.题目如下: s:="123" ps:=&s b:=[]byte(s) pb:=&b s ...

  5. java  JDK配置环境变量

    1)将下载的jdk放置到一定文件夹中,注意文件夹名不能有中文! 2)设置环境变量 a.可以在系统变量中找到path这个变量,然后将jdk下的bin的根目录添加进去 注意:一定要放在path变量值的最前 ...

  6. jenkins+docker 持续构建非docker in docker

    工欲善其事必先利其器,为了解脱程序员的,我们程序员本身发明了很多好用的工具,通过各种工具的组合来达到我们想要的结果 本文采用jenkins docker svn maven作为相关工具,项目sprin ...

  7. Github泄露扫描系统

    Github leaked patrol Github leaked patrol为一款github泄露巡航工具: 提供了WEB管理端,后台数据库支持SQLITE3.MYSQL和POSTGRES 双引 ...

  8. 给Ubuntu18.04安装mac os主题

    安装完的效果: 参考: https://linuxhint.com/gnome-tweak-tool-ubuntu-17-10/ ----------------------------------- ...

  9. TensorFlow TensorBoard使用

    摘要: 1.代码例子 2.主要功能内容: 1.代码例子 <TensorFlow实战>使用MLP处理Mnist数据集并TensorBoard上显示 2.主要功能 执行TensorBoard程 ...

  10. r.js合并实践 --项目中用到require.js做生产时模块开发 r.js build.js配置详解

    本文所用源代码已上传,需要的朋友自行下载:点我下载 第一步: 全局安装  npm install -g requirejs 第二步: 1.以下例子主要实现功能, 1)引用jq库获取dom中元素文本, ...