diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8beb8ea --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,4 @@ +--- +linters: + disable: + - errcheck diff --git a/bot/bot.go b/bot/bot.go index 039a7f8..6d5810c 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -72,7 +72,9 @@ func (b *Bot) RegisterHandlers() { func Run() error { setupConfig() - lib.SeedMathRand() + if err := lib.SeedMathRand(); err != nil { + log.Warn(err) + } if C.DiscordToken == "" { log.Fatalf("Discord token is not set") @@ -99,7 +101,7 @@ func Run() error { defer dg.Close() sc := make(chan os.Signal, 1) - signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) + signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM) <-sc log.Info("Shutting down") diff --git a/bot/command.go b/bot/command.go index 6159636..f9cf256 100644 --- a/bot/command.go +++ b/bot/command.go @@ -77,7 +77,9 @@ func (b *Bot) CommandHandler() func(*discordgo.Session, *discordgo.MessageCreate cmd.Config = b.Config log.Debugf("command: %v, args: %v, nargs: %d", cmd.Name, args, len(args)) - cmd.Func(args, m) + if err := cmd.Func(args, m); err != nil { + log.Errorf("failed to execute command: %s", err) + } return } diff --git a/bot/deal.go b/bot/deal.go index dc68211..7f46c5c 100644 --- a/bot/deal.go +++ b/bot/deal.go @@ -75,9 +75,7 @@ func (b *Bot) DealCommand() CommandFunc { } func JoinCards(h []Card, sep string) string { - var b []string - - b = make([]string, len(h)) + b := make([]string, len(h)) for i, v := range h { b[i] = string(v) diff --git a/bot/roulette.go b/bot/roulette.go index c5360a7..f418b43 100644 --- a/bot/roulette.go +++ b/bot/roulette.go @@ -36,7 +36,7 @@ func (g *Gun) Load(n int) { g.N = 0 for i := 1; i <= n; { x := lib.RandInt(0, len(g.C)-1) - if g.C[x] == false { + if !g.C[x] { g.C[x] = true i++ } else { @@ -58,7 +58,7 @@ func (g *Gun) Fire() bool { func (g *Gun) IsEmpty() bool { for _, v := range g.C { - if v == true { + if v { return false } } diff --git a/lib/common.go b/lib/common.go index d7de19e..ba26469 100644 --- a/lib/common.go +++ b/lib/common.go @@ -17,9 +17,7 @@ func Contains[T comparable](s []T, v T) bool { } func JoinInt(a []int, sep string) string { - var b []string - - b = make([]string, len(a)) + b := make([]string, len(a)) for i, v := range a { b[i] = strconv.Itoa(v) @@ -37,11 +35,7 @@ func SumInt(a []int) int { } func Itob(v int) bool { - if v == 1 { - return true - } - - return false + return v == 1 } func BuildURI(rawuri, rawpath string) string {