From 561315e1d616fd490c1ec720e7a825e3ed916249 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 16 Nov 2017 10:12:02 +0000 Subject: [PATCH] Add gofmt linter (#339) * Check that gofmt has been run * gofmt files * Tabs and spaces --- linter-fast.json | 1 + linter.json | 1 + .../dendrite/clientapi/routing/createroom.go | 2 +- .../matrix-org/dendrite/clientapi/routing/voip.go | 12 ++++++------ .../dendrite/cmd/dendrite-room-server/main.go | 2 +- .../matrix-org/dendrite/common/config/config.go | 2 +- src/github.com/matrix-org/dendrite/common/log.go | 2 +- .../federationsender/consumers/roomserver.go | 2 +- .../federationsender/queue/destinationqueue.go | 2 +- .../dendrite/federationsender/queue/queue.go | 2 +- .../dendrite/mediaapi/fileutils/fileutils.go | 2 +- .../matrix-org/dendrite/mediaapi/routing/download.go | 2 +- .../dendrite/mediaapi/thumbnailer/thumbnailer.go | 2 +- .../mediaapi/thumbnailer/thumbnailer_bimg.go | 2 +- .../mediaapi/thumbnailer/thumbnailer_nfnt.go | 2 +- .../dendrite/publicroomsapi/consumers/roomserver.go | 2 +- .../dendrite/syncapi/consumers/clientapi.go | 2 +- .../dendrite/syncapi/consumers/roomserver.go | 2 +- .../syncapi/storage/output_room_events_table.go | 2 +- .../matrix-org/dendrite/syncapi/sync/request.go | 2 +- 20 files changed, 25 insertions(+), 23 deletions(-) diff --git a/linter-fast.json b/linter-fast.json index aa86054e..81188d79 100644 --- a/linter-fast.json +++ b/linter-fast.json @@ -11,6 +11,7 @@ "misspell", "errcheck", "vet", + "gofmt", "goconst" ] } diff --git a/linter.json b/linter.json index 511c244b..de4f2bf6 100644 --- a/linter.json +++ b/linter.json @@ -17,6 +17,7 @@ "errcheck", "vet", "megacheck", + "gofmt", "goconst" ] } diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go b/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go index 078a7319..c84c1f7c 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/createroom.go @@ -23,7 +23,6 @@ import ( "github.com/matrix-org/dendrite/roomserver/api" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/clientapi/auth/storage/accounts" "github.com/matrix-org/dendrite/clientapi/httputil" @@ -33,6 +32,7 @@ import ( "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" + log "github.com/sirupsen/logrus" ) // https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/voip.go b/src/github.com/matrix-org/dendrite/clientapi/routing/voip.go index e699a91f..c4c48bd7 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/voip.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/voip.go @@ -24,16 +24,16 @@ import ( "time" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" + "github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/util" - "github.com/matrix-org/dendrite/clientapi/httputil" ) type turnServerResponse struct { - Username string `json:"username"` - Password string `json:"password"` - URIs []string `json:"uris"` - TTL int `json:"ttl"` + Username string `json:"username"` + Password string `json:"password"` + URIs []string `json:"uris"` + TTL int `json:"ttl"` } // RequestTurnServer implements: @@ -54,7 +54,7 @@ func RequestTurnServer(req *http.Request, device *authtypes.Device, cfg config.D resp := turnServerResponse{ URIs: turnConfig.URIs, - TTL: int(duration.Seconds()), + TTL: int(duration.Seconds()), } if turnConfig.SharedSecret != "" { diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go index f607d1ec..06773972 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite-room-server/main.go @@ -20,7 +20,6 @@ import ( _ "net/http/pprof" "os" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/roomserver/alias" @@ -28,6 +27,7 @@ import ( "github.com/matrix-org/dendrite/roomserver/query" "github.com/matrix-org/dendrite/roomserver/storage" "github.com/prometheus/client_golang/prometheus" + log "github.com/sirupsen/logrus" sarama "gopkg.in/Shopify/sarama.v1" ) diff --git a/src/github.com/matrix-org/dendrite/common/config/config.go b/src/github.com/matrix-org/dendrite/common/config/config.go index 82bdc3dc..65a9f898 100644 --- a/src/github.com/matrix-org/dendrite/common/config/config.go +++ b/src/github.com/matrix-org/dendrite/common/config/config.go @@ -25,8 +25,8 @@ import ( "strings" "time" - "github.com/sirupsen/logrus" "github.com/matrix-org/gomatrixserverlib" + "github.com/sirupsen/logrus" "golang.org/x/crypto/ed25519" "gopkg.in/yaml.v2" diff --git a/src/github.com/matrix-org/dendrite/common/log.go b/src/github.com/matrix-org/dendrite/common/log.go index f5c5bf34..fbfa3478 100644 --- a/src/github.com/matrix-org/dendrite/common/log.go +++ b/src/github.com/matrix-org/dendrite/common/log.go @@ -18,8 +18,8 @@ import ( "os" "path/filepath" - "github.com/sirupsen/logrus" "github.com/matrix-org/dugong" + "github.com/sirupsen/logrus" ) type utcFormatter struct { diff --git a/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go b/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go index a396aaf6..45e48f16 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go +++ b/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go @@ -19,7 +19,6 @@ import ( "encoding/json" "fmt" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/federationsender/queue" @@ -27,6 +26,7 @@ import ( "github.com/matrix-org/dendrite/federationsender/types" "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/gomatrixserverlib" + log "github.com/sirupsen/logrus" sarama "gopkg.in/Shopify/sarama.v1" ) diff --git a/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go b/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go index 265dbbc3..2013a7a4 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go +++ b/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go @@ -20,8 +20,8 @@ import ( "sync" "time" - log "github.com/sirupsen/logrus" "github.com/matrix-org/gomatrixserverlib" + log "github.com/sirupsen/logrus" ) // destinationQueue is a queue of events for a single destination. diff --git a/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go b/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go index 87b040be..d31c12f9 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go +++ b/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go @@ -18,8 +18,8 @@ import ( "fmt" "sync" - log "github.com/sirupsen/logrus" "github.com/matrix-org/gomatrixserverlib" + log "github.com/sirupsen/logrus" ) // OutgoingQueues is a collection of queues for sending transactions to other diff --git a/src/github.com/matrix-org/dendrite/mediaapi/fileutils/fileutils.go b/src/github.com/matrix-org/dendrite/mediaapi/fileutils/fileutils.go index 1d527528..36b2c5b8 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/fileutils/fileutils.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/fileutils/fileutils.go @@ -25,9 +25,9 @@ import ( "path/filepath" "strings" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/mediaapi/types" + log "github.com/sirupsen/logrus" ) // GetPathFromBase64Hash evaluates the path to a media file from its Base64Hash diff --git a/src/github.com/matrix-org/dendrite/mediaapi/routing/download.go b/src/github.com/matrix-org/dendrite/mediaapi/routing/download.go index eba3038f..2ce2993f 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/routing/download.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/routing/download.go @@ -28,7 +28,6 @@ import ( "strings" "sync" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/mediaapi/fileutils" @@ -38,6 +37,7 @@ import ( "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/pkg/errors" + log "github.com/sirupsen/logrus" ) const mediaIDCharacters = "A-Za-z0-9_=-" diff --git a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer.go b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer.go index efef03b5..61b66ebc 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer.go @@ -22,10 +22,10 @@ import ( "path/filepath" "sync" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/mediaapi/storage" "github.com/matrix-org/dendrite/mediaapi/types" + log "github.com/sirupsen/logrus" ) type thumbnailFitness struct { diff --git a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_bimg.go b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_bimg.go index 17802868..db6f23ac 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_bimg.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_bimg.go @@ -21,10 +21,10 @@ import ( "os" "time" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/mediaapi/storage" "github.com/matrix-org/dendrite/mediaapi/types" + log "github.com/sirupsen/logrus" "gopkg.in/h2non/bimg.v1" ) diff --git a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go index 4348e2bc..e9276731 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go @@ -28,11 +28,11 @@ import ( "os" "time" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/mediaapi/storage" "github.com/matrix-org/dendrite/mediaapi/types" "github.com/nfnt/resize" + log "github.com/sirupsen/logrus" ) // GenerateThumbnails generates the configured thumbnail sizes for the source file diff --git a/src/github.com/matrix-org/dendrite/publicroomsapi/consumers/roomserver.go b/src/github.com/matrix-org/dendrite/publicroomsapi/consumers/roomserver.go index 46e38b10..b7d42b11 100644 --- a/src/github.com/matrix-org/dendrite/publicroomsapi/consumers/roomserver.go +++ b/src/github.com/matrix-org/dendrite/publicroomsapi/consumers/roomserver.go @@ -18,11 +18,11 @@ import ( "context" "encoding/json" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/publicroomsapi/storage" "github.com/matrix-org/dendrite/roomserver/api" + log "github.com/sirupsen/logrus" sarama "gopkg.in/Shopify/sarama.v1" ) diff --git a/src/github.com/matrix-org/dendrite/syncapi/consumers/clientapi.go b/src/github.com/matrix-org/dendrite/syncapi/consumers/clientapi.go index 4eb4be39..d05a7692 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/consumers/clientapi.go +++ b/src/github.com/matrix-org/dendrite/syncapi/consumers/clientapi.go @@ -18,11 +18,11 @@ import ( "context" "encoding/json" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/syncapi/storage" "github.com/matrix-org/dendrite/syncapi/sync" + log "github.com/sirupsen/logrus" sarama "gopkg.in/Shopify/sarama.v1" ) diff --git a/src/github.com/matrix-org/dendrite/syncapi/consumers/roomserver.go b/src/github.com/matrix-org/dendrite/syncapi/consumers/roomserver.go index cefd3f1e..677eeb42 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/consumers/roomserver.go +++ b/src/github.com/matrix-org/dendrite/syncapi/consumers/roomserver.go @@ -19,7 +19,6 @@ import ( "encoding/json" "fmt" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common/config" "github.com/matrix-org/dendrite/roomserver/api" @@ -27,6 +26,7 @@ import ( "github.com/matrix-org/dendrite/syncapi/sync" "github.com/matrix-org/dendrite/syncapi/types" "github.com/matrix-org/gomatrixserverlib" + log "github.com/sirupsen/logrus" sarama "gopkg.in/Shopify/sarama.v1" ) diff --git a/src/github.com/matrix-org/dendrite/syncapi/storage/output_room_events_table.go b/src/github.com/matrix-org/dendrite/syncapi/storage/output_room_events_table.go index 8f268b48..fb00ad84 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/storage/output_room_events_table.go +++ b/src/github.com/matrix-org/dendrite/syncapi/storage/output_room_events_table.go @@ -18,11 +18,11 @@ import ( "context" "database/sql" - log "github.com/sirupsen/logrus" "github.com/lib/pq" "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/syncapi/types" "github.com/matrix-org/gomatrixserverlib" + log "github.com/sirupsen/logrus" ) const outputRoomEventsSchema = ` diff --git a/src/github.com/matrix-org/dendrite/syncapi/sync/request.go b/src/github.com/matrix-org/dendrite/syncapi/sync/request.go index 4754e664..7dec55fe 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/sync/request.go +++ b/src/github.com/matrix-org/dendrite/syncapi/sync/request.go @@ -20,9 +20,9 @@ import ( "strconv" "time" - log "github.com/sirupsen/logrus" "github.com/matrix-org/dendrite/syncapi/types" "github.com/matrix-org/util" + log "github.com/sirupsen/logrus" ) const defaultSyncTimeout = time.Duration(30) * time.Second