forked from spddl/GoInterruptPolicy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bat
42 lines (34 loc) · 983 Bytes
/
build.bat
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
@echo off
SET GOOS=windows
SET GOARCH=amd64
SET filename=GoInterruptPolicy
@REM for %%I in (.) do set "filename=%%~nxI"
:loop
CLS
@REM gocritic check -enable="#performance" ./...
gocritic check -enableAll -disable="#experimental,#opinionated,#commentedOutCode" ./...
IF exist %filename%.exe (
FOR /F "usebackq" %%A IN ('%filename%.exe') DO SET /A beforeSize=%%~zA
) ELSE (
SET /A beforeSize=0
)
: Build https://golang.org/cmd/go/
:: go build -v -ldflags="-w -s" -o %filename%.exe
go build -ldflags="-w -s -H windowsgui" -o %filename%.exe
FOR /F "usebackq" %%A IN ('%filename%.exe') DO SET /A size=%%~zA
SET /A diffSize = %size% - %beforeSize%
SET /A size=(%size%/1024)+1
IF %diffSize% EQU 0 (
ECHO %size% kb
) ELSE (
IF %diffSize% GTR 0 (
ECHO %size% kb [+%diffSize% b]
) ELSE (
ECHO %size% kb [%diffSize% b]
)
)
: Run
@REM IF %ERRORLEVEL% EQU 0 start /B /wait build/%filename%.exe
IF %ERRORLEVEL% EQU 0 %filename%.exe
PAUSE
GOTO loop