Use gofmt -s

This commit is contained in:
Jannis Mattheis
2018-03-24 19:24:57 +01:00
committed by Jannis Mattheis
parent 8d7c7a5a50
commit 0f2e7cf5e2
16 changed files with 31 additions and 29 deletions

View File

@@ -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"))
}

View File

@@ -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.

View File

@@ -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{

View File

@@ -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) {

View File

@@ -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.

View File

@@ -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 (

View File

@@ -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) {

View File

@@ -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"`

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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")
}
}
}

View File

@@ -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")
})
}
}

View File

@@ -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

View File

@@ -20,4 +20,3 @@ type VersionInfo struct {
// example: 2018-02-27T19:36:10.5045044+01:00
BuildDate string `json:"buildDate"`
}

View File

@@ -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.

View File

@@ -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")