M auth/bearer.go => auth/bearer.go +1 -1
@@ 57,7 57,7 @@ func DecodeBearerToken(token string) *BearerToken {
mac := payload[len(payload)-32:]
payload = payload[:len(payload)-32]
- if crypto.BearerVerify(payload, mac) == false {
+ if !crypto.BearerVerify(payload, mac) {
log.Printf("Invalid bearer token: HMAC verification failed (MAC: [%d]%s; payload: [%d]%s",
len(mac), hex.EncodeToString(mac), len(payload), hex.EncodeToString(payload))
return nil
M client/graphql.go => client/graphql.go +2 -3
@@ 6,7 6,6 @@ import (
"encoding/json"
"fmt"
"io"
- "io/ioutil"
"mime/multipart"
"net/http"
"net/textproto"
@@ 25,7 24,7 @@ type GraphQLQuery struct {
}
type InternalAuth struct {
- Name string `json:"name",omitempty`
+ Name string `json:"name,omitempty"`
ClientID string `json:"client_id"`
NodeID string `json:"node_id"`
}
@@ 148,7 147,7 @@ func Do(ctx context.Context, username string, svc string,
}
defer resp.Body.Close()
- respBody, err := ioutil.ReadAll(resp.Body)
+ respBody, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
M email/send.go => email/send.go +4 -3
@@ 81,11 81,12 @@ func mailSetup(ctx context.Context) (*smtp.Client, *mail.Address, error) {
var c *smtp.Client
addr := fmt.Sprintf("%s:%d", mailconf.host, mailconf.port)
- if mailconf.enctype == "tls" {
+ switch mailconf.enctype {
+ case "tls":
c, err = smtp.DialTLS(addr, nil)
- } else if mailconf.enctype == "starttls" {
+ case "starttls":
c, err = smtp.DialStartTLS(addr, nil)
- } else {
+ default:
c, err = smtp.Dial(addr)
}
if err != nil {
M webhooks/legacy.go => webhooks/legacy.go +2 -3
@@ 6,14 6,12 @@ import (
"database/sql"
"fmt"
"io"
- "io/ioutil"
"log"
"net/http"
"slices"
"strings"
"time"
- "git.sr.ht/~sircmpwn/dowork"
sq "github.com/Masterminds/squirrel"
"github.com/google/uuid"
"github.com/vaughan0/go-ini"
@@ 21,6 19,7 @@ import (
"git.sr.ht/~sircmpwn/core-go/config"
"git.sr.ht/~sircmpwn/core-go/crypto"
"git.sr.ht/~sircmpwn/core-go/database"
+ work "git.sr.ht/~sircmpwn/dowork"
)
type LegacyQueue struct {
@@ 227,7 226,7 @@ func deliverPayload(ctx context.Context, name, url string,
defer resp.Body.Close()
reader := io.LimitReader(resp.Body, 65536) // No more than 64 KiB
- body, err := ioutil.ReadAll(reader)
+ body, err := io.ReadAll(reader)
if err != nil {
return fmt.Errorf("Error reading response body: %v: %w",
err, work.ErrDoNotReattempt)
M webhooks/legacy_test.go => webhooks/legacy_test.go +2 -2
@@ 3,7 3,7 @@ package webhooks
import (
"context"
"database/sql/driver"
- "io/ioutil"
+ "io"
"net/http"
"net/http/httptest"
"strings"
@@ 67,7 67,7 @@ func TestDelivery(t *testing.T) {
assert.Equal(t, "profile:update", r.Header.Get("X-Webhook-Event"))
assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
- b, err := ioutil.ReadAll(r.Body)
+ b, err := io.ReadAll(r.Body)
assert.Nil(t, err)
assert.Equal(t, `{"hello": "world"}`, string(b))
M webhooks/queue.go => webhooks/queue.go +1 -2
@@ 6,7 6,6 @@ import (
"database/sql"
"fmt"
"io"
- "io/ioutil"
"log"
"net/http"
"strings"
@@ 241,7 240,7 @@ func (queue *WebhookQueue) deliverPayload(ctx context.Context,
defer resp.Body.Close()
reader := io.LimitReader(resp.Body, 262144) // No more than 256 KiB
- body, err := ioutil.ReadAll(reader)
+ body, err := io.ReadAll(reader)
if err != nil {
return fmt.Errorf("Error reading response body: %v: %w",
err, work.ErrDoNotReattempt)