1
0
Files
network-topology-discovery/build.bat
T
Your Name 8b7dbf2886 Fix: 替换SQLite为JSON文件存储,无需CGO支持
- 移除go-sqlite3依赖,改用纯Go的JSON文件存储
- 解决Windows上CGO_ENABLED=0导致SQLite无法使用的问题
- 添加线程安全的读写锁保护
- 支持数据持久化,重启后数据不丢失
- 简化存储逻辑,提高可靠性
2026-04-26 00:46:37 +08:00

72 行
1.8 KiB
Batchfile

@echo off
chcp 65001 >nul 2>&1
echo ========================================
echo Network Topology Discovery System - Build Script
echo ========================================
echo.
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] Building program...
set GOOS=windows
set GOARCH=amd64
set CGO_ENABLED=1
set CXX=x86_64-w64-mingw32-g++
go build -o network-topology.exe -ldflags="-s -w" ./cmd
if %ERRORLEVEL% NEQ 0 (
echo.
echo Build failed!
pause
exit /b 1
)
echo.
echo [3/3] Creating config file example...
if not exist config.json (
echo Creating default config file...
echo {> config.json
echo "scan_ranges": ["192.168.1.0/24"],>> config.json
echo "devices": [],>> config.json
echo "ssh": {>> config.json
echo "timeout": 10,>> config.json
echo "max_retries": 3,>> config.json
echo "port": 22>> config.json
echo },>> config.json
echo "web": {>> config.json
echo "port": 8080,>> config.json
echo "host": "0.0.0.0">> config.json
echo },>> config.json
echo "scanner": {>> config.json
echo "concurrency": 10,>> config.json
echo "timeout": 2>> config.json
echo }>> config.json
echo }>> config.json
)
echo.
echo ========================================
echo Build Complete!
echo ========================================
echo.
echo Usage:
echo network-topology.exe (Use default config)
echo network-topology.exe config.json (Use specified config)
echo.
echo Web UI: http://localhost:8080
echo.
pause