-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathbuild.bat
More file actions
97 lines (87 loc) · 1.99 KB
/
Copy pathbuild.bat
File metadata and controls
97 lines (87 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@echo off
setlocal enabledelayedexpansion
::vars
set EXEC_NAME=rest-api.exe
::param jump
if "%1"=="" goto all
if "%1"=="all" goto all
if "%1"=="setup" goto setup
if "%1"=="docs" goto docs
if "%1"=="doc" goto docs
if "%1"=="checks" goto checks
if "%1"=="check" goto checks
if "%1"=="test" goto test
if "%1"=="tests" goto test
if "%1"=="build" goto build
if "%1"=="clean" goto clean
echo Unknown target: %1
echo Available targets: setup, docs, check, test, build, clean, all
exit /b 1
:all
call :setup
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
call :checks
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
call :test
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
call :build
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
exit /b 0
:setup
echo Performing setup...
go install honnef.co/go/tools/cmd/staticcheck@latest
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
go install golang.org/x/tools/cmd/goimports@latest
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
go install github.com/swaggo/swag/cmd/swag@latest
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
echo Setup done!
echo.
exit /b 0
:docs
echo Generating docs...
swag fmt -d rest
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
swag init -d rest -g server.go -o rest\docs --outputTypes yaml,go
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
echo Docs generated!
echo.
exit /b 0
:checks
echo Performing checks...
go mod tidy
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
go vet ./...
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
staticcheck ./...
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
gofmt -w .
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
goimports -w .
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
echo Checks done!
echo.
exit /b 0
:test
echo Testing...
go test ./... -count=1
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
echo Testing complete!
echo.
exit /b 0
:build
call :docs
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
echo Building...
go build -o %EXEC_NAME% .\rest
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
echo Build complete!
echo.
exit /b 0
:clean
echo Cleaning...
if exist %EXEC_NAME% del /f /q %EXEC_NAME%
if exist rest\%EXEC_NAME% del /f /q rest\%EXEC_NAME%
echo Clean complete!
echo.
exit /b 0