From 0f2e7cf5e2467bbe643cffb99cd86eaddd786389 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sat, 24 Mar 2018 19:24:57 +0100 Subject: [PATCH] Use gofmt -s --- api/internalutil.go | 5 +++-- api/message.go | 2 +- api/stream/stream.go | 7 ++++--- api/stream/stream_test.go | 2 +- api/user.go | 2 +- auth/authentication.go | 2 +- auth/util_test.go | 2 +- config/config.go | 4 ++-- docs/swagger_test.go | 2 +- error/handler_test.go | 2 +- mode/mode.go | 10 +++++----- mode/mode_test.go | 6 +++--- model/error.go | 4 ++-- model/version.go | 1 - router/router.go | 4 ++-- ui/serve.go | 5 +++-- 16 files changed, 31 insertions(+), 29 deletions(-) diff --git a/api/internalutil.go b/api/internalutil.go index a4f3b2a..659bb1a 100644 --- a/api/internalutil.go +++ b/api/internalutil.go @@ -1,14 +1,15 @@ package api import ( - "github.com/gin-gonic/gin" "errors" "strconv" + + "github.com/gin-gonic/gin" ) func withID(ctx *gin.Context, name string, f func(id uint)) { if id, err := strconv.ParseUint(ctx.Param(name), 10, 32); err == nil { - f(uint(id)); + f(uint(id)) } else { ctx.AbortWithError(400, errors.New("invalid id")) } diff --git a/api/message.go b/api/message.go index ad3d726..18e57f1 100644 --- a/api/message.go +++ b/api/message.go @@ -66,7 +66,7 @@ func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) { } else { ctx.AbortWithError(404, errors.New("application does not exists")) } - }); + }) } // DeleteMessage deletes a message with an id. diff --git a/api/stream/stream.go b/api/stream/stream.go index a4587a9..2d08325 100644 --- a/api/stream/stream.go +++ b/api/stream/stream.go @@ -4,13 +4,14 @@ import ( "sync" "time" + "net/http" + "net/url" + "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "github.com/gotify/server/auth" - "github.com/gotify/server/model" - "net/http" "github.com/gotify/server/mode" - "net/url" + "github.com/gotify/server/model" ) var upgrader = websocket.Upgrader{ diff --git a/api/stream/stream_test.go b/api/stream/stream_test.go index 5d23bc7..ef82892 100644 --- a/api/stream/stream_test.go +++ b/api/stream/stream_test.go @@ -19,9 +19,9 @@ import ( "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "github.com/gotify/server/auth" + "github.com/gotify/server/mode" "github.com/gotify/server/model" "github.com/stretchr/testify/assert" - "github.com/gotify/server/mode" ) func TestFailureOnNormalHttpRequest(t *testing.T) { diff --git a/api/user.go b/api/user.go index d6ed250..918592d 100644 --- a/api/user.go +++ b/api/user.go @@ -5,8 +5,8 @@ import ( "github.com/gin-gonic/gin" "github.com/gotify/server/auth" - "github.com/gotify/server/model" "github.com/gotify/server/auth/password" + "github.com/gotify/server/model" ) // The UserDatabase interface for encapsulating database access. diff --git a/auth/authentication.go b/auth/authentication.go index 5f09ac3..2f09a53 100644 --- a/auth/authentication.go +++ b/auth/authentication.go @@ -4,8 +4,8 @@ import ( "errors" "github.com/gin-gonic/gin" - "github.com/gotify/server/model" "github.com/gotify/server/auth/password" + "github.com/gotify/server/model" ) const ( diff --git a/auth/util_test.go b/auth/util_test.go index d0a8af9..84a5442 100644 --- a/auth/util_test.go +++ b/auth/util_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/gin-gonic/gin" + "github.com/gotify/server/mode" "github.com/gotify/server/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/gotify/server/mode" ) func TestUtilSuite(t *testing.T) { diff --git a/config/config.go b/config/config.go index 83bc3d7..d69edaa 100644 --- a/config/config.go +++ b/config/config.go @@ -6,13 +6,13 @@ import "github.com/jinzhu/configor" type Configuration struct { Server struct { Port int `default:"80"` - SSL struct { + SSL struct { Enabled *bool `default:"false"` RedirectToHTTPS *bool `default:"true"` Port int `default:"443"` CertFile string `default:""` CertKey string `default:""` - LetsEncrypt struct { + LetsEncrypt struct { Enabled *bool `default:"false"` AcceptTOS *bool `default:"false"` Cache string `default:"certs"` diff --git a/docs/swagger_test.go b/docs/swagger_test.go index cd2af99..7e5e605 100644 --- a/docs/swagger_test.go +++ b/docs/swagger_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/stretchr/testify/assert" "github.com/gotify/server/mode" + "github.com/stretchr/testify/assert" ) func TestServe(t *testing.T) { diff --git a/error/handler_test.go b/error/handler_test.go index 0295b9e..c764adb 100644 --- a/error/handler_test.go +++ b/error/handler_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/gin-gonic/gin" + "github.com/gotify/server/mode" "github.com/gotify/server/model" "github.com/stretchr/testify/assert" - "github.com/gotify/server/mode" ) func TestDefaultErrorInternal(t *testing.T) { diff --git a/mode/mode.go b/mode/mode.go index 55ee084..4857528 100644 --- a/mode/mode.go +++ b/mode/mode.go @@ -11,22 +11,22 @@ const ( TestDev = "testdev" ) -var mode = Dev; +var mode = Dev // Set sets the new mode. func Set(newMode string) { - mode = newMode; + mode = newMode updateGinMode() } // Get returns the current mode. func Get() string { - return mode; + return mode } // IsDev returns true if the current mode is dev mode. func IsDev() bool { - return Get() == Dev || Get() == TestDev; + return Get() == Dev || Get() == TestDev } func updateGinMode() { @@ -40,4 +40,4 @@ func updateGinMode() { default: panic("unknown mode") } -} \ No newline at end of file +} diff --git a/mode/mode_test.go b/mode/mode_test.go index 249ae18..8b06166 100644 --- a/mode/mode_test.go +++ b/mode/mode_test.go @@ -2,8 +2,9 @@ package mode import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" ) func TestDevMode(t *testing.T) { @@ -13,7 +14,6 @@ func TestDevMode(t *testing.T) { assert.Equal(t, gin.Mode(), gin.DebugMode) } - func TestTestDevMode(t *testing.T) { Set(TestDev) assert.Equal(t, Get(), TestDev) @@ -32,4 +32,4 @@ func TestInvalidMode(t *testing.T) { assert.Panics(t, func() { Set("asdasda") }) -} \ No newline at end of file +} diff --git a/model/error.go b/model/error.go index e8bc4aa..4fff570 100644 --- a/model/error.go +++ b/model/error.go @@ -10,12 +10,12 @@ type Error struct { // // required: true // example: Unauthorized - Error string `json:"error"` + Error string `json:"error"` // The http error code. // // required: true // example: 401 - ErrorCode int `json:"errorCode"` + ErrorCode int `json:"errorCode"` // The http error code. // // required: true diff --git a/model/version.go b/model/version.go index 5f78832..47542c7 100644 --- a/model/version.go +++ b/model/version.go @@ -20,4 +20,3 @@ type VersionInfo struct { // example: 2018-02-27T19:36:10.5045044+01:00 BuildDate string `json:"buildDate"` } - diff --git a/router/router.go b/router/router.go index 266c401..3826095 100644 --- a/router/router.go +++ b/router/router.go @@ -13,11 +13,11 @@ import ( "net/http" + "github.com/gotify/server/api/stream" "github.com/gotify/server/config" "github.com/gotify/server/docs" - "github.com/gotify/server/model" - "github.com/gotify/server/api/stream" "github.com/gotify/server/mode" + "github.com/gotify/server/model" ) // Create creates the gin engine with all routes. diff --git a/ui/serve.go b/ui/serve.go index bcab5c7..2c5c59e 100644 --- a/ui/serve.go +++ b/ui/serve.go @@ -1,9 +1,10 @@ package ui import ( - "github.com/gobuffalo/packr" - "github.com/gin-gonic/gin" "net/http" + + "github.com/gin-gonic/gin" + "github.com/gobuffalo/packr" ) var box = packr.NewBox("../ui/build")