#!/usr/bin/env bash
#为了兼容windows下的bash
cd $GOPATH;
#创建 $GOPATH/src/golang.org/x 目录
mkdir -p $GOPATH/src/golang.org/x;
echo "已经安装的golang.org/x package";
ls;
echo "下面一行 for in 中包的名字可以自定义"
for name in "glog" "image" "perf" "snappy" "term" "sync" "winstrap" "cwg" "leveldb" "text" "net" "build" "protobuf" "dep" "sys" "crypto" "gddo" "tools" "scratch" "proposal" "mock" "oauth2" "freetype" "debug" "mobile" "gofrontend" "lint" "appengine" "geo" "review" "arch" "vgo" "exp" "time";do
cd $GOPATH/src/golang.org/x;
if [ -d "$name" ]
then
cd $name;
echo $name "包已经存在,使用git pull来更新源码";
git pull;
else
git_url="https://github.com/golang/${name}.git";
echo "开始clone golang.org/x 在github.com上的镜像代码:${git_url}";
git clone --depth 1 "$git_url";
cd $name;
fi
#go install;
done
参考:
https://segmentfault.com/a/1190000016310831?utm_source=tag-newest
有疑问加站长微信联系(非本文作者)