From 0f509e780962ca1cc8f4fc01943a6e701bd5baff Mon Sep 17 00:00:00 2001 From: iTanken <23544702+iTanken@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20=E4=BF=AE=E6=94=B9=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=BC=80=E5=8F=91=E7=9B=B8=E5=85=B3=E6=89=B9=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _dev/script/go-staticcheck.bat | 27 +++++++++++++++++++++------ _dev/script/go-vulncheck.bat | 25 ++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/_dev/script/go-staticcheck.bat b/_dev/script/go-staticcheck.bat index 5f3d722..1ff00e3 100644 --- a/_dev/script/go-staticcheck.bat +++ b/_dev/script/go-staticcheck.bat @@ -3,14 +3,29 @@ color 07 title 静态检查 :: file-encoding=GBK rem by iTanken -echo 开始进行静态检查... & echo. -cd /d %~dp0/../../ +echo. +if "%~dp0" equ "%CD%\" ( + cd /d %~dp0/../../ +) +echo 脚本所在路径:%~dp0 +echo 当前工作目录:%CD%\ +echo. +echo 开始进行静态检查... echo. & echo [golangci-lint.run] -rem go1.20 latest => v1.55.2 -go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 run -echo. & echo [staticcheck.io] -go run honnef.co/go/tools/cmd/staticcheck@latest -f text ./... +setlocal +where golangci-lint >nul 2>&1 +if "%ERRORLEVEL%" equ "0" ( + echo local golangci-lint... + golangci-lint run --timeout=5m +) else ( + echo "go1.20 latest => golangci-lint@v1.55.2" + go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 run --timeout=5m +) +endlocal + +rem echo. & echo [staticcheck.io] +rem go run honnef.co/go/tools/cmd/staticcheck@latest -f text ./... call "%~dp0/done-time-pause.bat" diff --git a/_dev/script/go-vulncheck.bat b/_dev/script/go-vulncheck.bat index 608701b..f4fb5bf 100644 --- a/_dev/script/go-vulncheck.bat +++ b/_dev/script/go-vulncheck.bat @@ -21,9 +21,28 @@ if %ver% leq 1.17 ( pause & exit ) -echo 开始进行漏洞检查... & echo. +if "%~dp0" equ "%CD%\" ( + cd /d %~dp0/../../ +) +echo 脚本所在路径:%~dp0 +echo 当前工作目录:%CD%\ +echo. +echo 开始进行漏洞检查... -cd /d %~dp0/../../ -go run golang.org/x/vuln/cmd/govulncheck@latest ./... +echo. & echo [govulncheck] +setlocal +where govulncheck >nul 2>&1 +if "%ERRORLEVEL%" equ "0" ( + echo local govulncheck... + govulncheck ./... +) else ( + if %ver% leq 1.20 ( + echo "go1.20 latest => govulncheck@v1.1.1" + go run golang.org/x/vuln/cmd/govulncheck@v1.1.1 ./... + ) else ( + go run golang.org/x/vuln/cmd/govulncheck@latest ./... + ) +) +endlocal call "%~dp0/done-time-pause.bat"