Format all go files

This commit is contained in:
Jannis Mattheis
2019-01-01 19:48:28 +01:00
parent 2a0e84cdcb
commit 68b160997d
14 changed files with 31 additions and 48 deletions

View File

@@ -1,18 +1,16 @@
package api package api
import ( import (
"math/rand"
"net/http/httptest"
"testing"
"strings"
"bytes" "bytes"
"errors" "errors"
"io" "io"
"io/ioutil" "io/ioutil"
"math/rand"
"mime/multipart" "mime/multipart"
"net/http/httptest"
"os" "os"
"strings"
"testing"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gotify/server/mode" "github.com/gotify/server/mode"

View File

@@ -3,11 +3,9 @@ package api
import ( import (
"math/rand" "math/rand"
"net/http/httptest" "net/http/httptest"
"testing"
"strings"
"net/url" "net/url"
"strings"
"testing"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gotify/server/mode" "github.com/gotify/server/mode"

View File

@@ -2,11 +2,10 @@ package api
import ( import (
"errors" "errors"
"strconv"
"strings" "strings"
"time" "time"
"strconv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding" "github.com/gin-gonic/gin/binding"
"github.com/gotify/location" "github.com/gotify/location"

View File

@@ -2,21 +2,18 @@ package api
import ( import (
"net/http/httptest" "net/http/httptest"
"net/url"
"strings"
"testing" "testing"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gotify/server/auth"
"github.com/gotify/server/mode" "github.com/gotify/server/mode"
"github.com/gotify/server/model" "github.com/gotify/server/model"
"github.com/gotify/server/test" "github.com/gotify/server/test"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"strings"
"net/url"
"github.com/gotify/server/auth"
) )
func TestMessageSuite(t *testing.T) { func TestMessageSuite(t *testing.T) {

View File

@@ -5,8 +5,8 @@
package stream package stream
import ( import (
"sync/atomic"
"sync" "sync"
"sync/atomic"
) )
// Modified version of sync.Once (https://github.com/golang/go/blob/master/src/sync/once.go) // Modified version of sync.Once (https://github.com/golang/go/blob/master/src/sync/once.go)
@@ -25,7 +25,7 @@ func (o *once) Do(f func()) {
} }
} }
func (o *once) mayExecute() bool { func (o *once) mayExecute() bool {
o.m.Lock() o.m.Lock()
defer o.m.Unlock() defer o.m.Unlock()
if o.done == 0 { if o.done == 0 {
@@ -33,4 +33,4 @@ func (o *once) mayExecute() bool {
return true return true
} }
return false return false
} }

View File

@@ -1,13 +1,12 @@
package stream package stream
import ( import (
"net/http"
"net/url"
"regexp" "regexp"
"sync" "sync"
"time" "time"
"net/http"
"net/url"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/gotify/server/auth" "github.com/gotify/server/auth"

View File

@@ -3,6 +3,7 @@ package stream
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@@ -10,8 +11,6 @@ import (
"testing" "testing"
"time" "time"
"errors"
"github.com/fortytw2/leaktest" "github.com/fortytw2/leaktest"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"

6
app.go
View File

@@ -1,12 +1,10 @@
package main package main
import ( import (
"math/rand"
"time"
"fmt" "fmt"
"math/rand"
"os" "os"
"time"
"github.com/gotify/server/config" "github.com/gotify/server/config"
"github.com/gotify/server/database" "github.com/gotify/server/database"

View File

@@ -44,7 +44,7 @@ type Configuration struct {
// Get returns the configuration extracted from env variables or config file. // Get returns the configuration extracted from env variables or config file.
func Get() *Configuration { func Get() *Configuration {
conf := new(Configuration) conf := new(Configuration)
err := configor.New(&configor.Config{EnvironmentPrefix: "GOTIFY"}).Load(conf, "config.yml", "/etc/gotify/config.yml") err := configor.New(&configor.Config{EnvironmentPrefix: "GOTIFY"}).Load(conf, "config.yml", "/etc/gotify/config.yml")
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@@ -2,9 +2,8 @@ package config
import ( import (
"os" "os"
"testing"
"path/filepath" "path/filepath"
"testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@@ -1,9 +1,10 @@
package docs package docs
import ( import (
"strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gobuffalo/packr" "github.com/gobuffalo/packr"
"strings"
) )
// Serve serves the documentation. // Serve serves the documentation.

View File

@@ -2,13 +2,11 @@ package error
import ( import (
"fmt" "fmt"
"github.com/gin-gonic/gin"
"net/http" "net/http"
"strings" "strings"
"unicode" "unicode"
"github.com/gin-gonic/gin"
"github.com/gotify/server/model" "github.com/gotify/server/model"
"gopkg.in/go-playground/validator.v8" "gopkg.in/go-playground/validator.v8"
) )

View File

@@ -1,24 +1,22 @@
package router package router
import ( import (
"net/http"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gotify/server/api"
"github.com/gotify/server/auth"
"github.com/gotify/server/database"
"github.com/gotify/server/error"
"github.com/gotify/server/ui"
"github.com/jmattheis/go-packr-swagger-ui"
"net/http"
"github.com/gotify/location" "github.com/gotify/location"
"github.com/gotify/server/api"
"github.com/gotify/server/api/stream" "github.com/gotify/server/api/stream"
"github.com/gotify/server/auth"
"github.com/gotify/server/config" "github.com/gotify/server/config"
"github.com/gotify/server/database"
"github.com/gotify/server/docs" "github.com/gotify/server/docs"
"github.com/gotify/server/error"
"github.com/gotify/server/mode" "github.com/gotify/server/mode"
"github.com/gotify/server/model" "github.com/gotify/server/model"
"github.com/gotify/server/ui"
"github.com/jmattheis/go-packr-swagger-ui"
) )
// Create creates the gin engine with all routes. // Create creates the gin engine with all routes.

View File

@@ -3,11 +3,10 @@ package runner
import ( import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"log"
"net" "net"
"net/http" "net/http"
"log"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gotify/server/config" "github.com/gotify/server/config"
"golang.org/x/crypto/acme/autocert" "golang.org/x/crypto/acme/autocert"