diff --git a/server/handlers/export.go b/server/handlers/export.go index 5478bd7..ad4807b 100644 --- a/server/handlers/export.go +++ b/server/handlers/export.go @@ -93,7 +93,7 @@ func (h *ExportHandler) Import(c *gin.Context) { } if raw, ok := data["machines"]; ok { - var list []models.Machine + list := []models.Machine{} if err := json.Unmarshal(raw, &list); err == nil { for _, m := range list { _, _ = db.DB.Exec(`INSERT OR IGNORE INTO machines (id, hostname, ip, mac, os_type, os_version, notes, ssh_port, ssh_username, ssh_password, is_online, cpu_info, memory_info, disk_info, uptime, listen_ports) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, @@ -103,7 +103,7 @@ func (h *ExportHandler) Import(c *gin.Context) { } if raw, ok := data["services"]; ok { - var list []models.Service + list := []models.Service{} if err := json.Unmarshal(raw, &list); err == nil { for _, s := range list { _, _ = db.DB.Exec(`INSERT OR IGNORE INTO services (id, machine_id, name, port, protocol, notes, target_machine_id, target_notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, @@ -113,7 +113,7 @@ func (h *ExportHandler) Import(c *gin.Context) { } if raw, ok := data["relationships"]; ok { - var list []models.Relationship + list := []models.Relationship{} if err := json.Unmarshal(raw, &list); err == nil { for _, r := range list { _, _ = db.DB.Exec(`INSERT OR IGNORE INTO relationships (id, source_machine_id, target_machine_id, relation_type, source_port, target_port, notes) VALUES (?, ?, ?, ?, ?, ?, ?)`, diff --git a/server/services/pve.go b/server/services/pve.go index b532cc7..27813f1 100644 --- a/server/services/pve.go +++ b/server/services/pve.go @@ -324,7 +324,7 @@ func (s *PVEHostService) GetAll() ([]models.PVEHost, error) { } defer rows.Close() - var hosts []models.PVEHost + hosts := []models.PVEHost{} for rows.Next() { var h models.PVEHost var verifySSL int