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. 导出Excel过程中遇到的问题java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException

    尝试实现java导出功能时遇到如下报错: org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.No ...

  2. Mysql和sqlite数据库操作心得

    经过最近一段时间的实际工作发现,原来只是认为Mysql和sqlite是分别独立的,数据传输和共享或有障碍,其实这是一个误区.当我们想要将sqlite中的数据存放到mysql中,最好的方法就是利用中间文 ...

  3. Ubuntu下MySQL主从同步配置

    一.在两台Linux机器上安装MySQL 二.Master主服务器配置(192.168.1.3) 1.编辑my.cnf编(命令查找文件位置:find / -name my.cnf) vi /etc/m ...

  4. Educational Codeforces Round 28

    A. Curriculum Vitae 题目链接:http://codeforces.com/contest/846/problem/A 题目意思:给你一个只包含0-1的数组,现在要求去可以去掉一些元 ...

  5. This module embeds Lua, via LuaJIT 2.0/2.1, into Nginx and by leveraging Nginx's subrequests, allows the integration of the powerful Lua threads (Lua coroutines) into the Nginx event model.

    openresty/lua-nginx-module: Embed the Power of Lua into NGINX HTTP servers https://github.com/openre ...

  6. Django - CBV、FBV

    一.FBV FBV(function base views) 就是在视图里使用函数处理请求. 在之前django的学习中,我们一直使用的是这种方式. 二.CBV CBV(class base view ...

  7. linux 安装libevent

    今天再ubuntu下安装libevent,下载源码 tar -xzvf libevent-1.4.15.tar.gz cd libevent-1.4.15 ./configure make make ...

  8. 控制HttpContext为null

    直接new一个 HttpContextBase _HttpContext= new HttpContextWrapper(System.Web.HttpContext.Current);

  9. 爬虫基础 - Robots协议

    Robots协议 指定一个robots.txt文件,告诉爬虫引擎怎么爬取 https://www.taobao.com/robots.txt User-agent: Baiduspider Allow ...

  10. sql server 2008维护计划配置

    转自:https://blog.csdn.net/yunye114105/article/details/6594826 一:目标任务: 使用SQL Server 2008自带的维护计划自动备份数据库 ...