Fix: 解决Win10中文乱码和编译路径问题

- 将批处理脚本改为英文输出
- 添加UTF-8编码支持(chcp 65001)
- 添加go.mod存在性检查
- 创建详细的Windows使用说明文档
This commit is contained in:
Your Name
2026-04-25 22:51:05 +08:00
parent d0927cbad5
commit 90d2a230a3
3 changed files with 208 additions and 21 deletions
+23 -11
View File
@@ -1,29 +1,41 @@
@echo off
chcp 65001 >nul 2>&1
echo ========================================
echo 网络拓扑发现系统 - 编译脚本
echo Network Topology Discovery System - Build Script
echo ========================================
echo.
echo [1/3] 清理旧文件...
REM Check if go.mod exists
if not exist go.mod (
echo Error: go.mod not found!
echo Please run this script from the project root directory.
echo.
echo Current directory: %CD%
echo.
pause
exit /b 1
)
echo [1/3] Cleaning old files...
if exist network-topology.exe del network-topology.exe
echo.
echo [2/3] 编译程序...
echo [2/3] Building program...
set GOOS=windows
set GOARCH=amd64
go build -o network-topology.exe -ldflags="-s -w" ./cmd
if %ERRORLEVEL% NEQ 0 (
echo.
echo 编译失败!
echo Build failed!
pause
exit /b 1
)
echo.
echo [3/3] 创建配置文件示例...
echo [3/3] Creating config file example...
if not exist config.json (
echo 创建默认配置文件...
echo Creating default config file...
echo {> config.json
echo "scan_ranges": ["192.168.1.0/24"],>> config.json
echo "devices": [],>> config.json
@@ -45,13 +57,13 @@ if not exist config.json (
echo.
echo ========================================
echo 编译完成!
echo Build Complete!
echo ========================================
echo.
echo 运行方式:
echo network-topology.exe (使用默认配置)
echo network-topology.exe config.json (使用指定配置文件)
echo Usage:
echo network-topology.exe (Use default config)
echo network-topology.exe config.json (Use specified config)
echo.
echo 访问地址: http://localhost:8080
echo Web UI: http://localhost:8080
echo.
pause