#!/bin/bash export GOPATH=$(cd $(dirname $0)/../;pwd) export PATH=${PATH}:${GOPATH}/bin curDir=$(cd $(dirname $0);pwd) cd ${curDir} which swag if [ $? -ne 0 ]; then echo "未发现swag,拉取最新swag" go get github.com/swaggo/swag/cmd/swag fi prepare=( "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" ) for goget in ${prepare[@]};do go get ${goget} if [ $? -ne 0 ]; then echo "拉取${goget}失败,终止构建" exit 1 fi done echo "package main;func main() {}" > main.go swag init --exclude web --output app/docs if [ $? -ne 0 ]; then echo "执行swag init失败,终止构建" rm main.go exit 1 fi swag init --exclude app --output web/docs if [ $? -ne 0 ]; then echo "执行swag init失败,终止构建" rm main.go exit 1 fi rm main.go