diff --git a/cmd/main.go b/cmd/main.go index 0821940..c662467 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -45,8 +45,8 @@ func cmdServer(ctx *cli.Context) error { server.StartServer() c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt) - <-c + signal.Notify(c, os.Interrupt) + <-c server.StopServer() os.Exit(0) diff --git a/cmd/server/server.go b/cmd/server/server.go index cb22059..f089fae 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -12,9 +12,9 @@ import ( ) type Server struct { - API *api.API - Auth *auth.AuthManager - Config *config.Config + API *api.API + Auth *auth.AuthManager + Config *config.Config Database *db.DBManager httpServer *http.Server } @@ -45,8 +45,8 @@ func (s *Server) StartServer() { err := s.httpServer.ListenAndServe() if err != nil { log.Error("Error starting server ", err) - return - } + return + } }() } diff --git a/internal/api/auth.go b/internal/api/auth.go index cee9d33..87387d9 100644 --- a/internal/api/auth.go +++ b/internal/api/auth.go @@ -8,7 +8,7 @@ import ( "encoding/json" "github.com/google/uuid" log "github.com/sirupsen/logrus" - "github.com/lestrrat-go/jwx/jwt" + "github.com/lestrrat-go/jwx/jwt" "reichard.io/imagini/internal/models" ) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 1845972..d26e84c 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -1,22 +1,21 @@ package auth import ( - "errors" + "fmt" + "time" + "errors" + "encoding/json" + "gorm.io/gorm" "github.com/google/uuid" - log "github.com/sirupsen/logrus" - "gorm.io/gorm" - "reichard.io/imagini/internal/db" - "reichard.io/imagini/internal/config" - "reichard.io/imagini/internal/models" - "reichard.io/imagini/internal/session" + log "github.com/sirupsen/logrus" + "github.com/lestrrat-go/jwx/jwa" + "github.com/lestrrat-go/jwx/jwt" - "encoding/json" - "fmt" - "time" - - "github.com/lestrrat-go/jwx/jwa" - "github.com/lestrrat-go/jwx/jwt" + "reichard.io/imagini/internal/db" + "reichard.io/imagini/internal/config" + "reichard.io/imagini/internal/models" + "reichard.io/imagini/internal/session" ) type AuthManager struct { diff --git a/internal/db/db.go b/internal/db/db.go index 62b6a6c..214ef08 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -1,15 +1,15 @@ package db import ( - "path" + "path" - "gorm.io/gorm" - // "gorm.io/gorm/logger" - "gorm.io/driver/sqlite" + "gorm.io/gorm" + // "gorm.io/gorm/logger" + "gorm.io/driver/sqlite" log "github.com/sirupsen/logrus" - "reichard.io/imagini/internal/config" - "reichard.io/imagini/internal/models" + "reichard.io/imagini/internal/config" + "reichard.io/imagini/internal/models" ) type DBManager struct { diff --git a/internal/db/devices.go b/internal/db/devices.go index 2fada0b..1a00bb2 100644 --- a/internal/db/devices.go +++ b/internal/db/devices.go @@ -4,7 +4,7 @@ import ( "github.com/google/uuid" log "github.com/sirupsen/logrus" - "reichard.io/imagini/internal/models" + "reichard.io/imagini/internal/models" ) func (dbm *DBManager) CreateDevice(device models.Device) (models.Device, error) { diff --git a/internal/db/users.go b/internal/db/users.go index 77d35be..6952ba3 100644 --- a/internal/db/users.go +++ b/internal/db/users.go @@ -4,7 +4,7 @@ import ( "golang.org/x/crypto/bcrypt" log "github.com/sirupsen/logrus" - "reichard.io/imagini/internal/models" + "reichard.io/imagini/internal/models" ) func (dbm *DBManager) CreateUser(user models.User) (models.User, error) { diff --git a/internal/models/db.go b/internal/models/db.go index bd02bc2..46e5463 100644 --- a/internal/models/db.go +++ b/internal/models/db.go @@ -1,17 +1,17 @@ package models import ( - "github.com/google/uuid" - "gorm.io/gorm" "time" + "gorm.io/gorm" + "github.com/google/uuid" ) // Base contains common columns for all tables. type Base struct { UUID uuid.UUID `gorm:"type:uuid;primarykey"` - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt gorm.DeletedAt `gorm:"index"` + CreatedAt time.Time + UpdatedAt time.Time + DeletedAt gorm.DeletedAt `gorm:"index"` } func (base *Base) BeforeCreate(tx *gorm.DB) (err error) { diff --git a/internal/session/session.go b/internal/session/session.go index ea001c9..477a22c 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -31,8 +31,8 @@ func (sm *SessionManager) Delete(key string) { sm.mutex.Lock() defer sm.mutex.Unlock() _, exists := sm.values[key] - if !exists { - return - } - delete(sm.values, key) + if !exists { + return + } + delete(sm.values, key) }