bash go_install_x_from_github.sh

 #!/bin/bash
 set +e
 # set -x
 echo 'GO Utilities: Install golang.org/x from github.com mirrors'
 echo '2019-02-01'

 function echo {
     command '\033[0m'
 }

 function warn {
     command '\033[0m'
 }

 function error {
     command '\033[0m'
 }

 function success {
     command '\033[0m'
 }

 #declare -a TOOLS=(tools net sys crypto text benchmarks image lint sync review perf scratch exp)
 declare -a TOOLS=(tools net sys crypto text benchmarks image lint sync)
 TMPPATH=$(mktemp -d)
 GITHUB_PREFIX=https://github.com/golang
 PARAM_DEPTH1=''
 PARAM_DISABLE_PULL=

  ]]
 do
     case "$1" in
     --help|-h)
         cat <<-EOF
         Usage:
             bash ${##*/} [Parameters]
         Parameters:
             --depth1|-d:        git clone --depth  xxx
             --disable-pull|-f:  Disable git pull
             --help|-h:          show help
         EOF
         exit
         ;;
     --depth1|-d)
         PARAM_DEPTH1=' --depth 1 '
         warn 'Enable depth 1 when git clone.'
         ;;
     --disable-pull|-f)
         PARAM_DISABLE_PULL=
         warn "Disable git pull."
         ;;
     esac
     shift
 done

 if [[ ! -e $GOPATH ]]; then
     error '$GOPATH is not found!'
     exit
 fi
 if [[ ! -e $GOPATH/src/golang.org/x ]]; then
     echo "Creating path $GOPATH/src/golang.org/x"
     mkdir -p $GOPATH/src/golang.org/x
 fi

 for a in ${TOOLS[@]}; do
      ]]; then
         if [[ -e $GOPATH/src/golang.org/x/$a/.git ]]; then
             cd $GOPATH/src/golang.org/x/$a
             git remote -v | grep "$GITHUB_PREFIX" > /dev/null
              ]]; then
                 echo "Pulling $a ..."
                 git pull --no-ff
                  ]]; then
                     echo "Installing $a ..."
                     go install golang.org/x/$a/...
                     [[ $? =  ]] && success 'success' || warn "Install $a failed!"
                 else
                     warn "Pull $a failed!"
                 fi
                 continue
             fi
         fi
     fi

     if [[ ! -e $TMPPATH ]]; then
         echo "Creating temp path $TMPPATH ..."
         mkdir -p $TMPPATH
     fi
     echo "CD $TMPPATH"
     cd $TMPPATH
     echo "Cloning $a ..."
     git clone $PARAM_DEPTH1 https://github.com/golang/${a}.git
      ]]; then
         echo "Moving $a to $GOPATH/src/golang.org/x/$a"
         rm -rf $GOPATH/src/golang.org/x/$a
         mv $a $GOPATH/src/golang.org/x/
          ]]; then
             echo "Installing $a ..."
             go install golang.org/x/$a/...
             [[ $? =  ]] && success 'success' || warn "Install $a failed!"
         else
             warn "Move $a failed!"
         fi
     else
         warn "Clone $a failed!"
     fi
 done

 echo "Removing temp path $TMPPATH ..."
 rm -rf $TMPPATH
 echo 'Done'

go_install_x_from_github.sh 从 github 安装 go x tools的更多相关文章

  1. Linux下安装Phalcon系统环境安装Phalcon 及 安装Phalcon Developer Tools

    一.安装Phalcon Phalcon 需要用的的PHP扩展函数有如下: curl gettext gd2 (to use the Phalcon\Image\Adapter\Gd class) li ...

  2. VS2015安装EF Power Tools

    前言 最近在研究EF觉得EF Power Tools比较强大,可以利用其特性来进行Code First模型验证等等,本以为在VS2015扩展和更新中能找到EF Power Tools,结果未找到,还得 ...

  3. GitHub安装配置

    GitHub安装配置1.安装Git-1.9.5-preview20141217 2.配置config文件Windows(在命令行下)cd /d %userprofile%if not exist &q ...

  4. 安装虚拟机VMware tools

    不懂得安装虚拟机VMware tools的想必都是刚在虚拟机上玩系统初学者,无疑我们对虚拟机的了解并不深,这使得本来很容易安装的VMware tools在我们安装时变得复杂而又难以琢磨,到头一直的付出 ...

  5. 【转】VMware 11安装Mac OS X 10.10 及安装Mac Vmware Tools.

    原文网址:http://www.cnblogs.com/Anand/p/4483727.html 先上一张效果图兴奋一下,博主穷屌丝一个,只能通过虚拟黑苹果体验下高富帅的生活,感觉超爽的,废话不多说的 ...

  6. VMware 11安装Mac OS X 10.10 及安装Mac Vmware Tools(超详细),以及动态调整虚拟机硬盘大小

    先上一张效果图兴奋一下,博主穷屌丝一个,只能通过虚拟黑苹果体验下高富帅的生活,感觉超爽的,废话不多说的,直接上图了! 目录: 1.安装所需软件下载: 2.Mac OS X10.10 安装基本步骤: 3 ...

  7. 关于安装了VMware tools后仍然不支持拖拽文件的问题

    我在学校机房里面的redhat4上面安装了VMware tools之后能正常支持拖拽,但是我自己电脑上的却不支持,折腾了好久,网上找了很久也还是没有解决,不过发现了一些问题,总结如下:(当然我总结的这 ...

  8. bin sh git@github.com no such file or directory

    window下使用git: 输入命令:git clone git @github.com:Alan0521/dotvim.git 出现/bin/sh:git@github.com no such fi ...

  9. OS X 10.9 Mavericks下如何安装Command Line Tools(命令行工具)

    OS X 10.9 Mavericks下如何安装Command Line Tools(命令行工具) 今天OS X 10.9 Mavericks正式发布,免费更新,立即去更新看看效果. 不过升级后安装命 ...

随机推荐

  1. struts2的琐碎知识点

    servlet:void init(ServletConfig cfg):// 读取servlet的配置参数void service(ServletRequest request, ServletRe ...

  2. Python开发【模块】:BeautifulSoup

    BeautifulSoup BeautifulSoup是一个模块,该模块用于接收一个HTML或XML字符串,然后将其进行格式化,之后遍可以使用他提供的方法进行快速查找指定元素,从而使得在HTML或XM ...

  3. IT运营新世界大会:广通软件开启双态运维大时代

    10月28日,第一届“IT运营新世界大会”在北京成功举办.大会上由10家ITOM领域的标杆企业宣布结成“ITOM联盟”. 广通软件(证券代码:833322)作为大会的创始成员全程推动见证了这一历史时刻 ...

  4. sql server学习路径地址

    联机丛书2005:https://docs.microsoft.com/zh-cn/previous-versions/sql/sql-server-2005/ms130214(v=sql.90) 联 ...

  5. ASP.Net Core 使用Redis实现分布式缓存

    本篇我们记录的内容是怎么在Core中使用Redis 和 SQL Server 实现分布式缓存. 一.文章概念描述   分布式缓存描述: 分布式缓存重点是在分布式上,相信大家接触过的分布式有很多中,像分 ...

  6. PhotoSwipe中文API(五)

    Responsive Images PhotoSwipe不支持<图片>或srcset,因为它要求所定义的图像的尺寸,并使用延迟加载.但是,随着图像动态加载,它很容易切换人士透露,即便是在旧 ...

  7. python之sqlalchemy使用

    一.介绍 SQLAlchemy是一个基于Python实现的ORM框架.该框架建立在 DB API之上,使用关系对象映射进行数据库操作,简言之便是:将类和对象转换成SQL,然后使用数据API执行SQL并 ...

  8. WCF For Silverlight跨域策略

    在WCF的根目录下添加跨域文件 <?xml version="1.0" encoding="utf-8" ?> <access-policy& ...

  9. 89. Gray Code(公式题)

    The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...

  10. 2017 Benelux Algorithm Programming Contest (BAPC 17) Solution

    A - Amsterdam Distance 题意:极坐标系,给出两个点,求最短距离 思路:只有两种方式,取min  第一种,先走到0点,再走到终点 第二种,走到同一半径,再走过去 #include ...