Skip to content

Commit 0a380c5

Browse files
committed
fix lint and error handling with status
1 parent 5c94a25 commit 0a380c5

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

cmd/machines.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ var machinesCmd = &cobra.Command{
160160

161161
info = utils.ParseJsonMessage(resp, "data")
162162

163-
machines.InsertMachines(db, info, title)
164-
cache.UpdateCacheDate(db, "machines_cache_date")
163+
err = machines.InsertMachines(db, info, title)
164+
if err != nil {
165+
log.Fatal(err)
166+
}
167+
err = cache.UpdateCacheDate(db, "machines_cache_date")
168+
if err != nil {
169+
log.Fatal(err)
170+
}
165171
} else {
166172
config.GlobalConfig.Logger.Info("Machine data recovery via cache")
167173
info, err = machines.GetMachinesFromCache(db, title)

cmd/status.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ func coreStatusCmd() (string, error) {
2121
return "", err
2222
}
2323

24+
if activeMachineData == nil {
25+
return "", nil
26+
}
27+
2428
ip := activeMachineData["ip"].(string)
2529
name := activeMachineData["name"].(string)
2630
os := activeMachineData["os"].(string)
@@ -29,10 +33,10 @@ func coreStatusCmd() (string, error) {
2933
stars := activeMachineData["stars"].(float64)
3034

3135
fmt.Println("---- Active Machine ----")
32-
fmt.Println(fmt.Sprintf("IP : %s", ip))
33-
fmt.Println(fmt.Sprintf("Name : %s", name))
34-
fmt.Println(fmt.Sprintf("OS : %s", os))
35-
fmt.Println(fmt.Sprintf("Stars : %v", stars))
36+
fmt.Printf("IP : %s\n", ip)
37+
fmt.Printf("Name : %s\n", name)
38+
fmt.Printf("OS : %s\n", os)
39+
fmt.Printf("Stars : %v\n", stars)
3640

3741
if authUserInUserOwns && authUserInRootOwns {
3842
link, err := utils.GetAchievementLink(int(activeMachineData["id"].(float64)))
@@ -44,8 +48,8 @@ func coreStatusCmd() (string, error) {
4448
fmt.Println(link)
4549
return "", nil
4650
}
47-
fmt.Println(fmt.Sprintf("User flag : %v", authUserInUserOwns))
48-
fmt.Println(fmt.Sprintf("Root flag : %v", authUserInRootOwns))
51+
fmt.Printf("User flag : %v\n", authUserInUserOwns)
52+
fmt.Printf("Root flag : %v\n", authUserInRootOwns)
4953
return "", nil
5054
}
5155

0 commit comments

Comments
 (0)