Fix: 替换SQLite为JSON文件存储,无需CGO支持
- 移除go-sqlite3依赖,改用纯Go的JSON文件存储 - 解决Windows上CGO_ENABLED=0导致SQLite无法使用的问题 - 添加线程安全的读写锁保护 - 支持数据持久化,重启后数据不丢失 - 简化存储逻辑,提高可靠性
This commit is contained in:
+11
-1
@@ -31,7 +31,17 @@ func (p *H3CParser) Parse(device *models.Device, outputs []string) error {
|
||||
}
|
||||
|
||||
p.parseVersion(device, outputs[0])
|
||||
device.Interfaces = p.parseInterfaces(outputs[1], outputs[2])
|
||||
|
||||
// 检查命令输出是否为空
|
||||
if outputs[1] == "" {
|
||||
fmt.Printf("Warning: 'display interface' output is empty for device %s\n", device.IP)
|
||||
} else {
|
||||
device.Interfaces = p.parseInterfaces(outputs[1], outputs[2])
|
||||
if len(device.Interfaces) == 0 {
|
||||
fmt.Printf("Warning: parsed 0 interfaces for device %s (output length: %d)\n",
|
||||
device.IP, len(outputs[1]))
|
||||
}
|
||||
}
|
||||
|
||||
// 解析ARP表用于MAC到IP映射(允许失败)
|
||||
arpTable := make(map[string]string)
|
||||
|
||||
Reference in New Issue
Block a user