Shell common command operations

  1. Determine whether the folder exists, and then perform the operation
# 准备pkg依赖,该命令可重复执行
if [ ! -d ${GOPATH}'/src/github.com/fwhezfwhez' ]; then
  mkdir -p ${GOPATH}/src/github.com/fwhezfwhez
fi
cd ${GOPATH}/src/github.com/fwhezfwhez
rm -rf pkg
git clone https://xxx.git pkg --depth 1;
  1. When the environment variable is not set correctly, stop execution and report an error
if [ -z ${GOPATH} ]
then
echo "$GOPATH 是空字符串,终止执行"
exit
fi
echo "$GOPATH 不是是空字符串"

echo 'service2'

Guess you like

Origin blog.csdn.net/fwhezfwhez/article/details/104969210