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. 安卓中通知(Notification)的基本使用方法

    1. 通知的使用场合 当某个应用程序希望向用户发出一些提示信息,而该应用程序又不在前台运行时,就可以借助通知来实现.发出一条通知后,手机最上方的状态栏中会显示一个通知的图标,下拉状态栏后可以看到通知的 ...

  2. UESTC 485 Game(康托展开,bfs打表)

    Game Time Limit: 4000/2000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit Status t ...

  3. codeforces #516---ABC

    A---golden plate http://codeforces.com/contest/1072/problem/A 题意:给一个n*m的格子,从最外层往里涂色,每次尽量涂最外面的那一圈,两圈涂 ...

  4. Network of Schools---poj1236(强连通分量)

    题目链接 题意:学校有一些单向网络,现在需要传一些文件 求:1,求最少需要向几个学校分发文件才能让每个学校都收到, 2,需要添加几条网络才能从任意一个学校分发都可以传遍所有学校. 解题思路(参考大神的 ...

  5. 省市县三级联动的SQL

    完整版见https://jadyer.github.io/ 首先是建表语句 CREATE TABLE `t_address_province` ( `id` INT AUTO_INCREMENT PR ...

  6. Parallel Decision Tree

    Decision Tree such as C4.5 is easy to parallel. Following is an example. This is a non-parallel vers ...

  7. Python统计字符串中的中英文字符、数字空格,特殊字符

    # -*- coding:utf8 -*- import string from collections import namedtuple def str_count(s): '''找出字符串中的中 ...

  8. cocos-lua基础学习(10)scheduler类学习笔记

    local scheduler = cc.Director:getInstance():getScheduler() local function shouldNotCrash(dt) end loc ...

  9. 学号20155311 2016-2017-2 《Java程序设计》第5周学习总结

    学号20155311 2016-2017-2 <Java程序设计>第5周学习总结 教材学习内容总结 由于我的ios系统出了一些问题,所以git idea jdk我都重新在windows系统 ...

  10. ng-深度学习-课程笔记-4: 浅层神经网络(Week3)

    1 神经网络概览( Neural Networks Overview ) 先来快速过一遍如何实现神经网络. 首先需要输入特征x,参数w和b,计算出z,然后用激活函数计算出a,在神经网络中我们要做多次这 ...