前言
旧版的go不支持module,所以包依赖需要手动引入。本文仅记录用过的脚本,方便以后复制。需要对具体的包增加具体的脚本
# 本脚本,需要在服务上预先配置好go 1.9, GOPATH,GOROOT.
# start
cd ${GOPATH}/src;
# 检查golang.org/x/... 下包是否完备
if [ ! -d "golang.org" ]; then
mkdir golang.org
fi
cd golang.org;
if [ ! -d "x" ]; then
mkdir x
fi
cd x;
if [ ! -d 'sys' ]; then
git clone https://github.com/golang/sys.git sys
fi
if [ ! -d 'text' ]; then
git clone https://github.com/golang/text.git text
fi
if [ ! -d 'time' ]; then
git clone https://github.com/golang/time.git time
fi
# 检查gopkg.in包下是否完备
cd ${GOPATH}/src;
if [ ! -d 'gopkg.in' ]; then
mkdir gopkg.in
fi
cd gopkg.in
if [ ! -d 'yaml.v2' ]; then
git clone https://github.com/go-yaml/yaml.git yaml.v2
fi
echo "check gopkg.in, golang.org/x done"
# 检查zonst/qipai/api 是否存在
cd ${GOPATH}/src;
if [ ! -d 'zonst' ]; then
mkdir zonst
fi
cd zonst
if [ ! -d 'qipai' ]; then
mkdir qipai
fi
cd qipai
if [ ! -d 'api' ]; then
mkdir api
fi
# go dep
go get -u -f github.com/fwhezfwhez/errorx
echo "go get errorx done"
go get -u -f github.com/fwhezfwhez/jsoncrack
echo "go get jsoncrack done"
go get -u -f github.com/fwhezfwhez/SuperChecker
echo "go get superchecker done"
go get -u -f github.com/spf13/viper
echo "go get viper done"
go get -u -f gopkg.in/gomail.v2
echo "go get gomail done"
go get -u -f github.com/shopspring/decimal
echo "go get decimal done"
go get -u -f github.com/rs/cors
echo "go get cors done"
go get -u -f github.com/getsentry/raven-go
echo "go get raven-go done"
go get -u -f github.com/fwhezfwhez/go-queue
echo "go get go-queue done"
go get -u -f github.com/gofrs/uuid
echo "go get uuid done"
使用时
在服务端下载该文件,然后./pkg_init.sh
权限不足时,确保该文件权限为777
chmod 777 pkg_init.sh