Fixed errcheck linter complaints

This commit is contained in:
2019-06-05 15:45:54 +09:00
parent 190a85fe08
commit 940e949a30
15 changed files with 112 additions and 33 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"github.com/akyoto/color"
"github.com/animenotifier/notify.moe/arn"
)
@ -33,17 +34,28 @@ func main() {
// Single user
user, err := arn.GetUserByNick(nick)
arn.PanicOnError(err)
addItemToUser(user)
err = addItemToUser(user)
arn.PanicOnError(err)
} else {
// All users
for user := range arn.StreamUsers() {
addItemToUser(user)
err = addItemToUser(user)
if err != nil {
color.Red(err.Error())
}
}
}
}
func addItemToUser(user *arn.User) {
func addItemToUser(user *arn.User) error {
inventory := user.Inventory()
inventory.AddItem(itemID, uint(quantity))
err := inventory.AddItem(itemID, uint(quantity))
if err != nil {
return err
}
inventory.Save()
return nil
}