From 5aac360f9c866ba72aff24f06091d9b95dba4d05 Mon Sep 17 00:00:00 2001 From: taynpg <taynpg@163.com> Date: Wed, 22 Jan 2025 10:34:46 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + build.bat | 44 ++++++++++++++++++++++++++++++++++++++++++++ main.go | 5 +++++ 3 files changed, 50 insertions(+) create mode 100644 build.bat diff --git a/.gitignore b/.gitignore index aeb7268..6fec0db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ downloads *.exe .DS_Store +build \ No newline at end of file diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..54fed7e --- /dev/null +++ b/build.bat @@ -0,0 +1,44 @@ +@echo off +REM ����Go������ļ��������Ŀ¼ +set SOURCE_FILE=main.go +set OUTPUT_DIR=build + +REM ����汾�� +set VERSION=v1.0 + +REM ����Ƿ�������Ŀ¼������������� +if not exist %OUTPUT_DIR% ( + mkdir %OUTPUT_DIR% +) + +REM ���� 32 λ Windows �汾 +echo Building 32-bit Windows version... +set GOOS=windows +set GOARCH=386 +go build -o %OUTPUT_DIR%\tooldown_%VERSION%.win.x86.exe %SOURCE_FILE% +if %ERRORLEVEL% neq 0 ( + echo Failed to build 32-bit Windows version. + exit /b 1 +) + +REM ���� 64 λ Windows �汾 +echo Building 64-bit Windows version... +set GOARCH=amd64 +go build -o %OUTPUT_DIR%\tooldown_%VERSION%.win.x64.exe %SOURCE_FILE% +if %ERRORLEVEL% neq 0 ( + echo Failed to build 64-bit Windows version. + exit /b 1 +) + +REM ���� 64 λ Linux �汾 +echo Building 64-bit Linux version... +set GOOS=linux +set GOARCH=amd64 +go build -o %OUTPUT_DIR%\tooldown_%VERSION%.linux.x64 %SOURCE_FILE% +if %ERRORLEVEL% neq 0 ( + echo Failed to build 64-bit Linux version. + exit /b 1 +) + +echo All builds completed successfully! +exit /b 0 diff --git a/main.go b/main.go index 0bc84f9..c698f5a 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "path/filepath" + "runtime" "sort" "strings" ) @@ -32,6 +33,10 @@ type Asset struct { } func main() { + + fmt.Printf("GOARCH: %s\n", runtime.GOARCH) + fmt.Printf("GOOS: %s\n", runtime.GOOS) + // 选择仓库 repo := chooseRepository(repositories) apiURL := convertToAPIURL(repo)