From f44afb103ebf949577e34dfa99c641f3c33a3c0d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 26 Aug 2021 11:14:15 +0000 Subject: [PATCH] go fmt --- auth/bearer.go | 6 +++--- auth/middleware.go | 2 +- client/graphql.go | 2 +- cmd/token/main.go | 2 +- config/config.go | 8 ++++---- email/send.go | 2 +- email/worker.go | 2 +- server/email.go | 2 +- webhooks/config.go | 2 +- webhooks/legacy.go | 2 +- webhooks/legacy_test.go | 8 ++++---- webhooks/queue.go | 10 +++++----- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/auth/bearer.go b/auth/bearer.go index e5aabaf3aa06abca7ee36a8f19c2df40f7982656..6755d9d209428e4e9ed9d12ea9e4d832009ca5e8 100644 --- a/auth/bearer.go +++ b/auth/bearer.go @@ -88,9 +88,9 @@ const ( type Grants struct { ReadOnly bool - all bool - grants map[string]string - encoded string + all bool + grants map[string]string + encoded string } func DecodeGrants(ctx context.Context, grants string) Grants { diff --git a/auth/middleware.go b/auth/middleware.go index c3ab5ffd447e7104ee70ac1c1589e53cb39ae0a2..08954c2db16ec6b409f6ff2b8ac8e7731e76ba23 100644 --- a/auth/middleware.go +++ b/auth/middleware.go @@ -85,7 +85,7 @@ func authError(w http.ResponseWriter, reason string, code int) { gqlerr := gqlerror.Errorf("Authentication error: %s", reason) b, err := json.Marshal(struct { Errors []*gqlerror.Error `json:"errors"` - } { + }{ Errors: []*gqlerror.Error{gqlerr}, }) if err != nil { diff --git a/client/graphql.go b/client/graphql.go index f4f47388951138413d633230cabee76e4252271c..1b93e8b675e48979d896b62eb032c8c33019aa13 100644 --- a/client/graphql.go +++ b/client/graphql.go @@ -50,7 +50,7 @@ func Execute(ctx context.Context, username string, svc string, Name: username, ClientID: config.ServiceName(ctx), // TODO: Populate this: - NodeID: "core-go", + NodeID: "core-go", } authBlob, err := json.Marshal(&auth) if err != nil { diff --git a/cmd/token/main.go b/cmd/token/main.go index de31da45163db1c6326fabfc97278f7a17b31802..e84a73b6b63abfa0ed7c2e7b7d393ffc58affde3 100644 --- a/cmd/token/main.go +++ b/cmd/token/main.go @@ -4,9 +4,9 @@ import ( "fmt" "os" + "git.sr.ht/~sircmpwn/core-go/auth" "git.sr.ht/~sircmpwn/core-go/config" "git.sr.ht/~sircmpwn/core-go/crypto" - "git.sr.ht/~sircmpwn/core-go/auth" ) func main() { diff --git a/config/config.go b/config/config.go index 24a20d2a3cd95590cc70e3b1099ac7aad90ca1de..102e14654e87f6ede9001725bd9850044a8316ed 100644 --- a/config/config.go +++ b/config/config.go @@ -38,10 +38,10 @@ func LoadConfig(defaultAddr string) ini.File { } for _, path := range []string{ - "config.ini", - "../config.ini", - "/etc/sr.ht/config.ini", - } { + "config.ini", + "../config.ini", + "/etc/sr.ht/config.ini", + } { config, err = ini.LoadFile(path) if err == nil { break diff --git a/email/send.go b/email/send.go index 204a900ec2e3da2aeb8ab61419e97e5fdead7241..df0f20afcd3a4640ee36828a435806c3552b8577 100644 --- a/email/send.go +++ b/email/send.go @@ -7,9 +7,9 @@ import ( "net/mail" "strconv" + _ "github.com/emersion/go-message/charset" "github.com/emersion/go-sasl" "github.com/emersion/go-smtp" - _ "github.com/emersion/go-message/charset" "git.sr.ht/~sircmpwn/core-go/config" ) diff --git a/email/worker.go b/email/worker.go index 1ebe91c04969e1f6dbea4814b09aef09caeacbbf..437864f71be7addb19186debf6ad7673080b2d27 100644 --- a/email/worker.go +++ b/email/worker.go @@ -13,10 +13,10 @@ import ( "time" "git.sr.ht/~sircmpwn/dowork" + _ "github.com/emersion/go-message/charset" "github.com/emersion/go-message/mail" "github.com/emersion/go-pgpmail" "golang.org/x/crypto/openpgp" - _ "github.com/emersion/go-message/charset" "git.sr.ht/~sircmpwn/core-go/config" ) diff --git a/server/email.go b/server/email.go index 1a9c8c226f44ed7a38eda5013e2c3e19a989916d..6fe00ab9d839269f8d061f9152fd2c9c5ac42a13 100644 --- a/server/email.go +++ b/server/email.go @@ -5,9 +5,9 @@ import ( "errors" "fmt" "log" + gomail "net/mail" "runtime" "strings" - gomail "net/mail" "github.com/99designs/gqlgen/graphql" "github.com/emersion/go-message/mail" diff --git a/webhooks/config.go b/webhooks/config.go index f93f4465dd7fc5874f280622215cba7cd1e16ea1..9faa70fb471070fdae93c5cb0d9db521615318fd 100644 --- a/webhooks/config.go +++ b/webhooks/config.go @@ -41,7 +41,7 @@ func NewAuthConfig(ctx context.Context) (AuthConfig, error) { _clientID := user.BearerToken.ClientID clientID = &_clientID } - return AuthConfig { + return AuthConfig{ AuthMethod: user.AuthMethod, TokenHash: &tokenHash, Grants: &grants, diff --git a/webhooks/legacy.go b/webhooks/legacy.go index b74e04be4914211ee88fbe3f8f6d9769d316a0bd..8c1a5f3fa0957190c233870a52e56e91a276e196 100644 --- a/webhooks/legacy.go +++ b/webhooks/legacy.go @@ -13,8 +13,8 @@ import ( "time" "git.sr.ht/~sircmpwn/dowork" - "github.com/google/uuid" sq "github.com/Masterminds/squirrel" + "github.com/google/uuid" "git.sr.ht/~sircmpwn/core-go/crypto" "git.sr.ht/~sircmpwn/core-go/database" diff --git a/webhooks/legacy_test.go b/webhooks/legacy_test.go index 2e2f078b37547774c76f42a440065fb6b8b50150..54c29765748d49dcbac9038ea5af6c7e05fc8ba6 100644 --- a/webhooks/legacy_test.go +++ b/webhooks/legacy_test.go @@ -11,9 +11,9 @@ import ( "time" "github.com/DATA-DOG/go-sqlmock" + sq "github.com/Masterminds/squirrel" "github.com/stretchr/testify/assert" "github.com/vaughan0/go-ini" - sq "github.com/Masterminds/squirrel" "git.sr.ht/~sircmpwn/core-go/crypto" "git.sr.ht/~sircmpwn/core-go/database" @@ -39,7 +39,7 @@ type argContains struct { matches []string } -func ArgMatchesAll(matches... string) *argContains { +func ArgMatchesAll(matches ...string) *argContains { return &argContains{matches} } @@ -100,7 +100,7 @@ func TestDelivery(t *testing.T) { WillReturnRows(sqlmock.NewRows([]string{ "sub.id", "sub.created", "sub.url", "sub.events", }).AddRow(1337, time.Now().UTC(), - srv.URL + "/webhook", "profile:update")). + srv.URL+"/webhook", "profile:update")). WithArgs(42, sqlmock.AnyArg()) // Any => events LIKE %profile:update% mock.ExpectCommit() @@ -132,7 +132,7 @@ func TestDelivery(t *testing.T) { "X-Webhook-Delivery", ), // Final request headers 4096). - WillReturnResult(sqlmock.NewResult(1, 1)) + WillReturnResult(sqlmock.NewResult(1, 1)) mock.ExpectCommit() ctx = database.Context(context.Background(), db) diff --git a/webhooks/queue.go b/webhooks/queue.go index b9c9e9745e13c231bcefd56e37103bb315ad24d0..2a4042871c5f3e988ac5404e0e962247cad00451 100644 --- a/webhooks/queue.go +++ b/webhooks/queue.go @@ -14,8 +14,8 @@ import ( "git.sr.ht/~sircmpwn/dowork" "github.com/99designs/gqlgen/graphql" - "github.com/google/uuid" sq "github.com/Masterminds/squirrel" + "github.com/google/uuid" "git.sr.ht/~sircmpwn/core-go/auth" "git.sr.ht/~sircmpwn/core-go/crypto" @@ -28,9 +28,9 @@ type WebhookQueue struct { } type WebhookSubscription struct { - ID int - URL string - Query string + ID int + URL string + Query string // See AuthConfig in webhooks/config.go for an explanation of these fields AuthMethod string TokenHash *string @@ -120,7 +120,7 @@ func (queue *WebhookQueue) fetchSubscriptions(ctx context.Context, var subs []*WebhookSubscription if err := database.WithTx(ctx, &sql.TxOptions{ Isolation: 0, - ReadOnly: true, + ReadOnly: true, }, func(tx *sql.Tx) error { var ( err error