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. Oracle数据库类型date

    date日期类型 说明 oracle dd-mm-yyyy create table test1(birthday date); timestamp(n) 说明:邮戳的时间类型 于date的区别,邮戳 ...

  2. Drainage Ditches---hdu1532(最大流)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1532 题意: 每次下雨的时候,农场主John的农场里就会形成一个池塘,这样就会淹没其中一小块土地,在这 ...

  3. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  4. spring requestmapping 拦截多个请求

    @RequestMapping(value = {"/picture_content/{id}","/attachment_content/{id}",&quo ...

  5. spark mllib和ml类里面的区别

    mllib是老的api,里面的模型都是基于RDD的,模型使用的时候api也是有变化的(model这里是naiveBayes), (1:在模型训练的时候是naiveBayes.run(data: RDD ...

  6. Redis持久化磁盘IO方式及其带来的问题

    有Redis线上运维经验的人会发现Redis在物理内存使用比较多,但还没有超过实际物理内存总容量时就会发生不稳定甚至崩溃的问题 一.对Redis持久化的探讨与理解 redis是一个支持持久化的内存数据 ...

  7. centos7.3下ScyllaDB1.6安装

    转自:http://10710016.blog.51cto.com/10700016/1900483 ScyllaDB 安装配置 1.说明: scylladb支持centos7.2 64位 及以上版本 ...

  8. (转)在GitHub多个帐号上添加SSH公钥

    GitHub后台可以添加多个SSH Keys,但是同一个SSH Keys只能在添加在一个帐号上(添加时提示“Key is already in use”).理由很容易想到,SSH公钥使用时相当于用户名 ...

  9. 关于ML的思考讲座-周zh-11.30日

    1.深度神经网络 1.以往神经网络采用单或双隐层结构,虽然参照了生物上的神经元,但是从本质上来说还是数学,以函数嵌套形成. 2.通常使用的激活函数是连续可微(differentiable)的,sigm ...

  10. python 面向对象编程学习总结

    面向对象是个抽象的东西,概念比较多,下面会一一介绍. 一.类和实例 类(Class)和实例(Instance)是面向对象最重要的概念. 类是指抽象出的模板.实例则是根据类创建出来的具体的“对象”,每个 ...