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"