Skip to content

Commit d2d5beb

Browse files
committed
move duplicate lint script content to a new repository.
1 parent d7fb363 commit d2d5beb

File tree

2 files changed

+3
-434
lines changed

2 files changed

+3
-434
lines changed

lint.bat

Lines changed: 1 addition & 261 deletions
Original file line numberDiff line numberDiff line change
@@ -1,262 +1,2 @@
11
@echo off
2-
3-
call :init
4-
call :main %1 %2
5-
exit /b %exit_code%
6-
7-
:init
8-
rem initialize environment variables
9-
set is_print_help=0
10-
set exit_code=0
11-
set exit_on_error=0
12-
goto :EOF
13-
rem END_init
14-
15-
:main
16-
rem process print help information
17-
call :is_print_help %1
18-
if %is_print_help% == 1 (
19-
call :print_help
20-
goto :EOF
21-
)
22-
rem process arguments
23-
if "%1" == "-e" (
24-
set exit_on_error=1
25-
)
26-
if "%2" == "-e" (
27-
set exit_on_error=1
28-
)
29-
rem start check code
30-
call :check_all %1
31-
rem check exit code
32-
if %exit_code% == 0 (
33-
echo all check passed
34-
) else (
35-
echo exit code: %exit_code%
36-
)
37-
goto :EOF
38-
rem END_main
39-
40-
:is_print_help
41-
if "%1" == "-help" (
42-
set is_print_help=1
43-
goto :EOF
44-
)
45-
if "%1" == "--help" (
46-
set is_print_help=1
47-
goto :EOF
48-
)
49-
if "%1" == "-h" (
50-
set is_print_help=1
51-
goto :EOF
52-
)
53-
goto :EOF
54-
rem END_is_print_help
55-
56-
:print_help
57-
echo Usage of lint:
58-
echo -golint only use golint to check code
59-
echo -gocyclo only use gocyclo to check code
60-
echo -cilint only use golangci-lint to check code
61-
echo -gosec only use gosec to check code
62-
echo -e interrupt script when detect error
63-
echo.
64-
echo example:
65-
echo "lint -golint" only use golint to check code
66-
echo "lint -gosec -e" only use gosec and exit on error
67-
goto :EOF
68-
rem END_print_help
69-
70-
:check_all
71-
rem -----------------Windows-----------------
72-
set GOOS=windows
73-
rem -----------------------------
74-
set GOARCH=amd64
75-
call :check %1
76-
rem --------exit on error--------
77-
if not exit_code == 0 (
78-
if %exit_on_error% == 1 (
79-
goto :EOF
80-
)
81-
)
82-
rem -----------------------------
83-
set GOARCH=386
84-
call :check %1
85-
rem --------exit on error--------
86-
if not exit_code == 0 (
87-
if %exit_on_error% == 1 (
88-
goto :EOF
89-
)
90-
)
91-
rem -----------------------------
92-
set GOARCH=arm64
93-
call :check %1
94-
rem --------exit on error--------
95-
if not exit_code == 0 (
96-
if %exit_on_error% == 1 (
97-
goto :EOF
98-
)
99-
)
100-
rem -----------------------------------------
101-
102-
rem ------------------Linux------------------
103-
set GOOS=linux
104-
rem -----------------------------
105-
set GOARCH=amd64
106-
call :check %1
107-
rem --------exit on error--------
108-
if not exit_code == 0 (
109-
if %exit_on_error% == 1 (
110-
goto :EOF
111-
)
112-
)
113-
rem -----------------------------
114-
set GOARCH=386
115-
call :check %1
116-
rem --------exit on error--------
117-
if not exit_code == 0 (
118-
if %exit_on_error% == 1 (
119-
goto :EOF
120-
)
121-
)
122-
rem -----------------------------
123-
set GOARCH=arm64
124-
call :check %1
125-
rem --------exit on error--------
126-
if not exit_code == 0 (
127-
if %exit_on_error% == 1 (
128-
goto :EOF
129-
)
130-
)
131-
rem -----------------------------------------
132-
133-
rem -----------------Darwin------------------
134-
set GOOS=darwin
135-
rem -----------------------------
136-
set GOARCH=amd64
137-
call :check %1
138-
rem --------exit on error--------
139-
if not exit_code == 0 (
140-
if %exit_on_error% == 1 (
141-
goto :EOF
142-
)
143-
)
144-
rem -----------------------------
145-
set GOARCH=arm64
146-
call :check %1
147-
rem --------exit on error--------
148-
if not exit_code == 0 (
149-
if %exit_on_error% == 1 (
150-
goto :EOF
151-
)
152-
)
153-
rem -----------------------------------------
154-
goto :EOF
155-
rem END_check_all
156-
157-
:check
158-
echo ================================================
159-
echo check %GOOS% %GOARCH%
160-
echo ------------------------------------------------
161-
162-
if "%1" == "-golint" (
163-
golint -set_exit_status -min_confidence 0.3 ./...
164-
call :set_exit_code
165-
call :echo_line
166-
goto :EOF
167-
)
168-
if "%1" == "-gocyclo" (
169-
gocyclo -avg -over 15 .
170-
call :set_exit_code
171-
call :echo_line
172-
goto :EOF
173-
)
174-
if "%1" == "-cilint" (
175-
golangci-lint run ./...
176-
call :set_exit_code
177-
call :echo_line
178-
goto :EOF
179-
)
180-
if "%1" == "-gosec" (
181-
gosec -quiet ./...
182-
call :set_exit_code
183-
call :echo_line
184-
goto :EOF
185-
)
186-
187-
echo ------------------------------------------------
188-
echo golint
189-
echo ------------------------------------------------
190-
golint -set_exit_status -min_confidence 0.3 ./...
191-
call :set_exit_code
192-
echo ------------------------------------------------
193-
echo.
194-
rem --------exit on error--------
195-
if not exit_code == 0 (
196-
if %exit_on_error% == 1 (
197-
goto :EOF
198-
)
199-
)
200-
rem -----------------------------
201-
202-
echo ------------------------------------------------
203-
echo gocyclo
204-
echo ------------------------------------------------
205-
gocyclo -avg -over 15 .
206-
call :set_exit_code
207-
echo ------------------------------------------------
208-
echo.
209-
rem --------exit on error--------
210-
if not exit_code == 0 (
211-
if %exit_on_error% == 1 (
212-
goto :EOF
213-
)
214-
)
215-
rem -----------------------------
216-
217-
echo ------------------------------------------------
218-
echo golangci-lint
219-
echo ------------------------------------------------
220-
golangci-lint run ./...
221-
call :set_exit_code
222-
echo ------------------------------------------------
223-
echo.
224-
rem --------exit on error--------
225-
if not exit_code == 0 (
226-
if %exit_on_error% == 1 (
227-
goto :EOF
228-
)
229-
)
230-
rem -----------------------------
231-
232-
echo ------------------------------------------------
233-
echo gosec
234-
echo ------------------------------------------------
235-
gosec -quiet ./...
236-
call :set_exit_code
237-
echo ------------------------------------------------
238-
call :echo_line
239-
rem --------exit on error--------
240-
if not exit_code == 0 (
241-
if %exit_on_error% == 1 (
242-
goto :EOF
243-
)
244-
)
245-
rem -----------------------------
246-
goto :EOF
247-
rem END_check
248-
249-
:set_exit_code
250-
if %ERRORLEVEL% == 0 (
251-
echo pass
252-
) else (
253-
set exit_code=1
254-
)
255-
goto :EOF
256-
rem END_set_exit_code
257-
258-
:echo_line
259-
echo ================================================
260-
echo.
261-
goto :EOF
262-
rem END_echo_line
2+
go-lints.bat

0 commit comments

Comments
 (0)