diff --git a/base/multi.go b/base/multi.go index b301cf61..04253e90 100644 --- a/base/multi.go +++ b/base/multi.go @@ -3,6 +3,7 @@ package base import ( "context" "database/sql" + "errors" "fmt" "sync" "time" @@ -77,7 +78,7 @@ func (m *multi) heartbeat() { `, m.timeoutSeconds), m.name) var id string if err := row.Scan(&id); err != nil { - if err != sql.ErrNoRows { + if !errors.Is(err, sql.ErrNoRows) { m.Errorf("failed to scan id: %s", err) return } diff --git a/gcalbot/gcalbot/reminderscheduler/sync.go b/gcalbot/gcalbot/reminderscheduler/sync.go index 10d5e638..c1e821f1 100644 --- a/gcalbot/gcalbot/reminderscheduler/sync.go +++ b/gcalbot/gcalbot/reminderscheduler/sync.go @@ -222,7 +222,8 @@ func (r *ReminderScheduler) AddSubscription(account *gcalbot.Account, subscripti account.KeybaseUsername, account.AccountNickname, subscription.CalendarID, subscription.KeybaseConvID, func(msg *ReminderMessage, _ func()) { r.minuteReminders.AddReminderMessageToMinute(subscription.DurationBefore, msg) - }) + }, + ) // do a background sync when a new subscription is added go r.syncEvents(account, &subscription) @@ -241,5 +242,6 @@ func (r *ReminderScheduler) RemoveSubscription(account *gcalbot.Account, subscri r.eventReminders.RemoveReminderMessageFromEvent(msg) removeReminderMessageFromSubscription() } - }) + }, + ) } diff --git a/gcalbot/gcalbot/schedulescheduler/send.go b/gcalbot/gcalbot/schedulescheduler/send.go index b0ace4e2..5718dbb5 100644 --- a/gcalbot/gcalbot/schedulescheduler/send.go +++ b/gcalbot/gcalbot/schedulescheduler/send.go @@ -2,6 +2,7 @@ package schedulescheduler import ( "context" + "errors" "fmt" "math" "strings" @@ -132,7 +133,8 @@ func (s *ScheduleScheduler) SendDailyScheduleMessage(sendMinute time.Time, subsc for index, calendarID := range subscription.CalendarIDs { cal, err := srv.Calendars.Get(calendarID).Fields("summary").Do() if err != nil { - if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 404 { + var gerr *googleapi.Error + if errors.As(err, &gerr) && gerr.Code == 404 { // Calendar was deleted or user lost access; use ID as display name s.Debug("calendar no longer accessible (404): %s", calendarID) } else { diff --git a/gcalbot/gcalbot/webhook.go b/gcalbot/gcalbot/webhook.go index 561d489f..0e62711a 100644 --- a/gcalbot/gcalbot/webhook.go +++ b/gcalbot/gcalbot/webhook.go @@ -50,12 +50,14 @@ func (h *HTTPSrv) handleEventUpdateWebhook(w http.ResponseWriter, r *http.Reques } reminderSubscriptions, err := h.db.GetReminderSubscriptionsByAccountAndCalendar( - ctx, account, channel.CalendarID, SubscriptionTypeReminder) + ctx, account, channel.CalendarID, SubscriptionTypeReminder, + ) if err != nil { return } inviteSubscriptions, err := h.db.GetReminderSubscriptionsByAccountAndCalendar( - ctx, account, channel.CalendarID, SubscriptionTypeInvite) + ctx, account, channel.CalendarID, SubscriptionTypeInvite, + ) if err != nil { return } diff --git a/githubbot/githubbot/handler.go b/githubbot/githubbot/handler.go index 5c0090f0..dd4fefd0 100644 --- a/githubbot/githubbot/handler.go +++ b/githubbot/githubbot/handler.go @@ -2,6 +2,7 @@ package githubbot import ( "context" + "errors" "fmt" "net/http" "strings" @@ -126,7 +127,7 @@ func (h *Handler) handleSubscribe(ctx context.Context, cmd string, msg chat1.Msg if !alreadyExists { if create { if created, err := h.handleNewSubscription(ctx, repo, msg, client); err != nil { - if _, ok := err.(base.OAuthRequiredError); ok { + if errors.As(err, new(base.OAuthRequiredError)) { return nil } return err @@ -153,7 +154,7 @@ func (h *Handler) handleSubscribe(ctx context.Context, cmd string, msg chat1.Msg } created, err := h.handleNewSubscription(ctx, repo, msg, client) if err != nil { - if _, ok := err.(base.OAuthRequiredError); ok { + if errors.As(err, new(base.OAuthRequiredError)) { return nil } return err diff --git a/githubbot/githubbot/http.go b/githubbot/githubbot/http.go index 7c43c8a4..07e8f89c 100644 --- a/githubbot/githubbot/http.go +++ b/githubbot/githubbot/http.go @@ -202,7 +202,8 @@ func (h *HTTPSrv) formatMessage(ctx context.Context, convID chat1.ConvIDStr, eve branch, len(event.Commits), commitMsgs, - event.GetCompare()), branch + event.GetCompare(), + ), branch case *github.CheckRunEvent: var author username diff --git a/gitlabbot/gitlabbot/http.go b/gitlabbot/gitlabbot/http.go index 554b7e74..760a2559 100644 --- a/gitlabbot/gitlabbot/http.go +++ b/gitlabbot/gitlabbot/http.go @@ -105,7 +105,8 @@ func (h *HTTPSrv) handleWebhook(_ http.ResponseWriter, r *http.Request) { branch, len(event.Commits), commitMsgs, - lastCommitDiffURL) + lastCommitDiffURL, + ) repo = event.Project.PathWithNamespace case *gitlab.PipelineEvent: repo = event.Project.PathWithNamespace diff --git a/triviabot/triviabot/session.go b/triviabot/triviabot/session.go index 20abfe0d..6358d20d 100644 --- a/triviabot/triviabot/session.go +++ b/triviabot/triviabot/session.go @@ -196,7 +196,7 @@ func (s *session) getNextQuestion() error { return nil } if err := getQuestion(token); err != nil { - if err == errTokenExpired { + if errors.Is(err, errTokenExpired) { s.Debug("getNextQuestion: token expired, trying again") if token, err = s.getToken(true); err != nil { s.Errorf("getNextQuestion: failed to get token: %s", err)