From 7e1841a2441e7f2a1185e352ee5bff2afa58f01c Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Sat, 13 Feb 2021 19:12:28 +0100 Subject: [PATCH] =?UTF-8?q?Dont=C2=B4t=20output=20empty=20fields=20in=20st?= =?UTF-8?q?ruct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 4 ++-- types.go | 44 ++++++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/main.go b/main.go index 99457b9..54a35d8 100644 --- a/main.go +++ b/main.go @@ -108,7 +108,7 @@ func processUcAPIs() ([]node, []link) { if err != nil { log.Fatalln(err) } - + var model = lookupModels(currentDevice.Model) nodes = append(nodes, node{ Firstseen: "0", Lastseen: time.Unix(int64(currentDevice.LastSeen), 0).Format(iso8601), @@ -140,7 +140,7 @@ func processUcAPIs() ([]node, []link) { Branch: "stable", }, NProc: 1, - Model: lookupModels(currentDevice.Model), + Model: model, }) } return nodes, links diff --git a/types.go b/types.go index 961f0c6..03ba1a5 100644 --- a/types.go +++ b/types.go @@ -97,34 +97,34 @@ type link struct { } type node struct { - Firstseen string `json:"firstseen"` - Lastseen string `json:"lastseen"` - IsOnline bool `json:"is_online"` - IsGateway bool `json:"is_gateway"` - Clients int `json:"clients"` - ClientsWifi24 int `json:"clients_wifi24"` - ClientsWifi5 int `json:"clients_wifi5"` - ClientsOther int `json:"clients_other"` - RootFSUsage int `json:"rootfs_usage"` - LoadAVG float64 `json:"loadavg"` - MemoryUsage float64 `json:"memory_usage"` - Uptime string `json:"uptime"` - GatewayNexthop string `json:"gateway_nexthop"` - Gateway string `json:"gateway"` + Firstseen string `json:"firstseen,omitempty"` + Lastseen string `json:"lastseen,omitempty"` + IsOnline bool `json:"is_online,omitempty"` + IsGateway bool `json:"is_gateway,omitempty"` + Clients int `json:"clients,omitempty"` + ClientsWifi24 int `json:"clients_wifi24,omitempty"` + ClientsWifi5 int `json:"clients_wifi5,omitempty"` + ClientsOther int `json:"clients_other,omitempty"` + RootFSUsage int `json:"rootfs_usage,omitempty"` + LoadAVG float64 `json:"loadavg,omitempty"` + MemoryUsage float64 `json:"memory_usage,omitempty"` + Uptime string `json:"uptime,omitempty"` + GatewayNexthop string `json:"gateway_nexthop,omitempty"` + Gateway string `json:"gateway,omitempty"` Location *struct { Longitude float64 `json:"longitude"` Latitude float64 `json:"latitude"` } `json:"location,omitempty"` - NodeID string `json:"node_id"` - MAC string `json:"mac"` - Adresses []string `json:"addresses"` - Domain string `json:"domain"` - Hostname string `json:"hostname"` - Owner string `json:"owner"` + NodeID string `json:"node_id,omitempty"` + MAC string `json:"mac,omitempty"` + Adresses []string `json:"addresses,omitempty"` + Domain string `json:"domain,omitempty"` + Hostname string `json:"hostname,omitempty"` + Owner string `json:"owner,omitempty"` Firmware firmware `json:"firmware"` Autoupdater autoupdater `json:"autoupdater"` - NProc int `json:"nproc"` - Model string `json:"model"` + NProc int `json:"nproc,omitempty"` + Model string `json:"model,omitempty"` } type firmware struct {