Fix lint errors
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ryan Cavicchioni 2022-09-07 00:54:58 -05:00
parent e2032942ca
commit 446ac616bf
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
6 changed files with 16 additions and 16 deletions

4
.golangci.yml Normal file
View File

@ -0,0 +1,4 @@
---
linters:
disable:
- errcheck

View File

@ -72,7 +72,9 @@ func (b *Bot) RegisterHandlers() {
func Run() error { func Run() error {
setupConfig() setupConfig()
lib.SeedMathRand() if err := lib.SeedMathRand(); err != nil {
log.Warn(err)
}
if C.DiscordToken == "" { if C.DiscordToken == "" {
log.Fatalf("Discord token is not set") log.Fatalf("Discord token is not set")
@ -99,7 +101,7 @@ func Run() error {
defer dg.Close() defer dg.Close()
sc := make(chan os.Signal, 1) 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 <-sc
log.Info("Shutting down") log.Info("Shutting down")

View File

@ -77,7 +77,9 @@ func (b *Bot) CommandHandler() func(*discordgo.Session, *discordgo.MessageCreate
cmd.Config = b.Config cmd.Config = b.Config
log.Debugf("command: %v, args: %v, nargs: %d", cmd.Name, args, len(args)) 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 return
} }

View File

@ -75,9 +75,7 @@ func (b *Bot) DealCommand() CommandFunc {
} }
func JoinCards(h []Card, sep string) string { 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 { for i, v := range h {
b[i] = string(v) b[i] = string(v)

View File

@ -36,7 +36,7 @@ func (g *Gun) Load(n int) {
g.N = 0 g.N = 0
for i := 1; i <= n; { for i := 1; i <= n; {
x := lib.RandInt(0, len(g.C)-1) x := lib.RandInt(0, len(g.C)-1)
if g.C[x] == false { if !g.C[x] {
g.C[x] = true g.C[x] = true
i++ i++
} else { } else {
@ -58,7 +58,7 @@ func (g *Gun) Fire() bool {
func (g *Gun) IsEmpty() bool { func (g *Gun) IsEmpty() bool {
for _, v := range g.C { for _, v := range g.C {
if v == true { if v {
return false return false
} }
} }

View File

@ -17,9 +17,7 @@ func Contains[T comparable](s []T, v T) bool {
} }
func JoinInt(a []int, sep string) string { 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 { for i, v := range a {
b[i] = strconv.Itoa(v) b[i] = strconv.Itoa(v)
@ -37,11 +35,7 @@ func SumInt(a []int) int {
} }
func Itob(v int) bool { func Itob(v int) bool {
if v == 1 { return v == 1
return true
}
return false
} }
func BuildURI(rawuri, rawpath string) string { func BuildURI(rawuri, rawpath string) string {