gildarts: 1 general cleanup 9 files changed, 18 insertions(+), 18 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~emersion/soju-dev/patches/33603/mbox | git am -3Learn more about email & git
fixes issues highlighted by go vet and go-staticcheck including - deprecated packages - unneeded use of *printf - unlabeled fields - capitalized error strings - deprecated functions - unused variables - unclear time math - unneeded use of the fmt package --- cmd/sojuctl/main.go | 4 ++-- contrib/znc-import/main.go | 2 +- downstream.go | 2 +- irc.go | 11 ++++++----- server.go | 4 ++-- service.go | 4 ++-- upstream.go | 4 ++-- user.go | 2 +- xirc/genmsg.go | 3 +-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/sojuctl/main.go b/cmd/sojuctl/main.go index 24ed1ec..844b4e8 100644 --- a/cmd/sojuctl/main.go +++ b/cmd/sojuctl/main.go @@ -10,7 +10,7 @@ import ( "os" "golang.org/x/crypto/bcrypt" - "golang.org/x/crypto/ssh/terminal" + terminal "golang.org/x/term" "git.sr.ht/~emersion/soju/config" "git.sr.ht/~emersion/soju/database" @@ -25,7 +25,7 @@ const usage = `usage: sojuctl [-config path] <action> [options...] func init() { flag.Usage = func() { - fmt.Fprintf(flag.CommandLine.Output(), usage) + fmt.Fprint(flag.CommandLine.Output(), usage) } } diff --git a/contrib/znc-import/main.go b/contrib/znc-import/main.go index afb6a9e..fa43e3a 100644 --- a/contrib/znc-import/main.go +++ b/contrib/znc-import/main.go @@ -32,7 +32,7 @@ Options: func init() { flag.Usage = func() { - fmt.Fprintf(flag.CommandLine.Output(), usage) + fmt.Fprint(flag.CommandLine.Output(), usage) } } diff --git a/downstream.go b/downstream.go index 8fdbceb..ce68bb0 100644 --- a/downstream.go +++ b/downstream.go @@ -1405,7 +1405,7 @@ func (dc *downstreamConn) loadNetwork(ctx context.Context) error { if !dc.srv.Config().MultiUpstream { return ircError{&irc.Message{ Command: irc.ERR_PASSWDMISMATCH, - Params: []string{dc.nick, fmt.Sprintf("Multi-upstream mode is disabled on this server")}, + Params: []string{dc.nick, "Multi-upstream mode is disabled on this server"}, }} } dc.isMultiUpstream = true diff --git a/irc.go b/irc.go index a75b914..5415e60 100644 --- a/irc.go +++ b/irc.go @@ -179,11 +179,12 @@ func (cm channelModes) Format() (modeString string, parameters []string) { const stdChannelTypes = "#&+!" var stdMemberships = []xirc.Membership{ - {'q', '~'}, // founder - {'a', '&'}, // protected - {'o', '@'}, // operator - {'h', '%'}, // halfop - {'v', '+'}, // voice + {Mode: 'q', Prefix: '~'}, // founder + {Mode: 'a', Prefix: '&'}, // protected + {Mode: 'o', Prefix: '@'}, // operator + {Mode: 'h', Prefix: '%'}, // halfop + {Mode: 'v', Prefix: '+'}, // voice + } func formatMemberPrefix(ms xirc.MembershipSet, dc *downstreamConn) string { diff --git a/server.go b/server.go index e47b0b3..cfc81de 100644 --- a/server.go +++ b/server.go @@ -39,7 +39,7 @@ var downstreamRegisterTimeout = 30 * time.Second var chatHistoryLimit = 1000 var backlogLimit = 4000 -var errWebPushSubscriptionExpired = fmt.Errorf("Web Push subscription expired") +var errWebPushSubscriptionExpired = fmt.Errorf("web push subscription expired") type Logger interface { Printf(format string, v ...interface{}) @@ -112,7 +112,7 @@ func NewRetryListener(ln net.Listener) net.Listener { func (ln *retryListener) Accept() (net.Conn, error) { for { conn, err := ln.Listener.Accept() - if ne, ok := err.(net.Error); ok && ne.Temporary() { + if ne, ok := err.(net.Error); ok && ne.Timeout() { if ln.delay == 0 { ln.delay = 5 * time.Millisecond } else { diff --git a/service.go b/service.go index 689555f..08f614b 100644 --- a/service.go +++ b/service.go @@ -599,7 +599,7 @@ func handleServiceNetworkUpdate(ctx context.Context, dc *downstreamConn, params } func handleServiceNetworkDelete(ctx context.Context, dc *downstreamConn, params []string) error { - net, params, err := getNetworkFromArg(dc, params) + net, _, err := getNetworkFromArg(dc, params) if err != nil { return err } @@ -620,7 +620,7 @@ func handleServiceNetworkQuote(ctx context.Context, dc *downstreamConn, params [ raw := params[len(params)-1] params = params[:len(params)-1] - net, params, err := getNetworkFromArg(dc, params) + net, _, err := getNetworkFromArg(dc, params) if err != nil { return err } diff --git a/upstream.go b/upstream.go index f556f47..eadbd6b 100644 --- a/upstream.go +++ b/upstream.go @@ -352,7 +352,7 @@ func (uc *upstreamConn) abortPendingCommands() { Params: []string{pendingCmd.msg.Command, "TEMPORARILY_UNAVAILABLE", pendingCmd.msg.Params[0], "Command aborted"}, }) default: - panic(fmt.Errorf("Unsupported pending command %q", pendingCmd.msg.Command)) + panic(fmt.Errorf("unsupported pending command %q", pendingCmd.msg.Command)) } } } @@ -373,7 +373,7 @@ func (uc *upstreamConn) enqueueCommand(dc *downstreamConn, msg *irc.Message) { case "LIST", "WHO", "WHOIS", "AUTHENTICATE", "REGISTER", "VERIFY": // Supported default: - panic(fmt.Errorf("Unsupported pending command %q", msg.Command)) + panic(fmt.Errorf("unsupported pending command %q", msg.Command)) } uc.pendingCmds[msg.Command] = append(uc.pendingCmds[msg.Command], pendingUpstreamCommand{ diff --git a/user.go b/user.go index b50628d..8216f62 100644 --- a/user.go +++ b/user.go @@ -242,7 +242,7 @@ func (net *network) run() { return } - delay := backoff.Next() - time.Now().Sub(lastTry) + delay := backoff.Next() - time.Since(lastTry) if delay > 0 { net.logger.Printf("waiting %v before trying to reconnect to %q", delay.Truncate(time.Second), net.Addr) time.Sleep(delay) diff --git a/xirc/genmsg.go b/xirc/genmsg.go index e796e9a..6686a7a 100644 --- a/xirc/genmsg.go +++ b/xirc/genmsg.go @@ -2,7 +2,6 @@ package xirc import ( "encoding/base64" - "fmt" "sort" "strings" @@ -119,7 +118,7 @@ func GenerateMOTD(prefix *irc.Prefix, nick string, motd string) []*irc.Message { msgs = append(msgs, &irc.Message{ Prefix: prefix, Command: irc.RPL_MOTDSTART, - Params: []string{nick, fmt.Sprintf("- Message of the Day -")}, + Params: []string{nick, "- Message of the Day -"}, }) for _, l := range strings.Split(motd, "\n") { -- 2.37.0