diff --git a/common/constants.go b/common/constants.go index 1437682..321a4d9 100644 --- a/common/constants.go +++ b/common/constants.go @@ -1,9 +1,10 @@ package common import ( - "github.com/google/uuid" "sync" "time" + + "github.com/google/uuid" ) var StartTime = time.Now().Unix() // unit: second diff --git a/common/embed-file-system.go b/common/embed-file-system.go index 3ea02cf..d7bd2d5 100644 --- a/common/embed-file-system.go +++ b/common/embed-file-system.go @@ -2,9 +2,10 @@ package common import ( "embed" - "github.com/gin-contrib/static" "io/fs" "net/http" + + "github.com/gin-contrib/static" ) // Credit: https://github.com/gin-contrib/static/issues/19 diff --git a/common/logger.go b/common/logger.go index 0b8b2cf..5c5a1b8 100644 --- a/common/logger.go +++ b/common/logger.go @@ -2,12 +2,13 @@ package common import ( "fmt" - "github.com/gin-gonic/gin" "io" "log" "os" "path/filepath" "time" + + "github.com/gin-gonic/gin" ) func SetupGinLog() { diff --git a/common/redis.go b/common/redis.go index 56db2b4..1d4f976 100644 --- a/common/redis.go +++ b/common/redis.go @@ -2,9 +2,10 @@ package common import ( "context" - "github.com/go-redis/redis/v8" "os" "time" + + "github.com/go-redis/redis/v8" ) var RDB *redis.Client diff --git a/common/utils.go b/common/utils.go index 6eb3a0f..14ea81e 100644 --- a/common/utils.go +++ b/common/utils.go @@ -2,7 +2,6 @@ package common import ( "fmt" - "github.com/google/uuid" "html/template" "log" "net" @@ -10,6 +9,8 @@ import ( "runtime" "strconv" "strings" + + "github.com/google/uuid" ) func OpenBrowser(url string) { diff --git a/common/verification.go b/common/verification.go index d8ccd6e..41fd3c9 100644 --- a/common/verification.go +++ b/common/verification.go @@ -1,10 +1,11 @@ package common import ( - "github.com/google/uuid" "strings" "sync" "time" + + "github.com/google/uuid" ) type verificationValue struct { diff --git a/controller/file.go b/controller/file.go index 0c1e2ef..d49d5fa 100644 --- a/controller/file.go +++ b/controller/file.go @@ -2,14 +2,16 @@ package controller import ( "fmt" - "gin-template/common" - "gin-template/model" - "github.com/gin-gonic/gin" "net/http" "path/filepath" "strconv" "strings" "time" + + "gin-template/common" + "gin-template/model" + + "github.com/gin-gonic/gin" ) func GetAllFiles(c *gin.Context) { diff --git a/controller/github.go b/controller/github.go index 780de43..f0c161f 100644 --- a/controller/github.go +++ b/controller/github.go @@ -5,13 +5,15 @@ import ( "encoding/json" "errors" "fmt" + "net/http" + "strconv" + "time" + "gin-template/common" "gin-template/model" + "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" - "net/http" - "strconv" - "time" ) type GitHubOAuthResponse struct { diff --git a/controller/misc.go b/controller/misc.go index 6e4c15d..f14464a 100644 --- a/controller/misc.go +++ b/controller/misc.go @@ -3,10 +3,12 @@ package controller import ( "encoding/json" "fmt" + "net/http" + "gin-template/common" "gin-template/model" + "github.com/gin-gonic/gin" - "net/http" ) func GetStatus(c *gin.Context) { diff --git a/controller/option.go b/controller/option.go index 394f289..360cfcf 100644 --- a/controller/option.go +++ b/controller/option.go @@ -2,11 +2,13 @@ package controller import ( "encoding/json" + "net/http" + "strings" + "gin-template/common" "gin-template/model" + "github.com/gin-gonic/gin" - "net/http" - "strings" ) func GetOptions(c *gin.Context) { diff --git a/controller/user.go b/controller/user.go index 767d3fc..4d2534c 100644 --- a/controller/user.go +++ b/controller/user.go @@ -2,14 +2,16 @@ package controller import ( "encoding/json" + "net/http" + "strconv" + "strings" + "gin-template/common" "gin-template/model" + "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" "github.com/google/uuid" - "net/http" - "strconv" - "strings" ) type LoginRequest struct { diff --git a/controller/wechat.go b/controller/wechat.go index f7d8dfc..56d9853 100644 --- a/controller/wechat.go +++ b/controller/wechat.go @@ -4,12 +4,14 @@ import ( "encoding/json" "errors" "fmt" - "gin-template/common" - "gin-template/model" - "github.com/gin-gonic/gin" "net/http" "strconv" "time" + + "gin-template/common" + "gin-template/model" + + "github.com/gin-gonic/gin" ) type wechatLoginResponse struct { diff --git a/main.go b/main.go index ad9a2e9..011a8db 100644 --- a/main.go +++ b/main.go @@ -2,17 +2,19 @@ package main import ( "embed" + "log" + "os" + "strconv" + "gin-template/common" "gin-template/middleware" "gin-template/model" "gin-template/router" + "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/cookie" "github.com/gin-contrib/sessions/redis" "github.com/gin-gonic/gin" - "log" - "os" - "strconv" ) //go:embed web/build diff --git a/middleware/auth.go b/middleware/auth.go index 07cedec..931a8ba 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -1,11 +1,13 @@ package middleware import ( + "net/http" + "gin-template/common" "gin-template/model" + "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" - "net/http" ) func authHelper(c *gin.Context, minRole int) { diff --git a/middleware/rate-limit.go b/middleware/rate-limit.go index 410ed19..575f2f7 100644 --- a/middleware/rate-limit.go +++ b/middleware/rate-limit.go @@ -3,10 +3,12 @@ package middleware import ( "context" "fmt" - "gin-template/common" - "github.com/gin-gonic/gin" "net/http" "time" + + "gin-template/common" + + "github.com/gin-gonic/gin" ) var timeFormat = "2006-01-02T15:04:05.000Z" diff --git a/middleware/turnstile-check.go b/middleware/turnstile-check.go index b7401b7..0a7aa84 100644 --- a/middleware/turnstile-check.go +++ b/middleware/turnstile-check.go @@ -2,11 +2,13 @@ package middleware import ( "encoding/json" + "net/http" + "net/url" + "gin-template/common" + "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" - "net/http" - "net/url" ) type turnstileCheckResponse struct { diff --git a/model/file.go b/model/file.go index 2ff7a1f..d1b2856 100644 --- a/model/file.go +++ b/model/file.go @@ -1,11 +1,13 @@ package model import ( + "os" + "path" + "gin-template/common" + _ "gorm.io/driver/sqlite" "gorm.io/gorm" - "os" - "path" ) type File struct { diff --git a/model/main.go b/model/main.go index 0a64651..2ca5497 100644 --- a/model/main.go +++ b/model/main.go @@ -1,11 +1,13 @@ package model import ( + "os" + "gin-template/common" + "gorm.io/driver/mysql" "gorm.io/driver/sqlite" "gorm.io/gorm" - "os" ) var DB *gorm.DB diff --git a/model/option.go b/model/option.go index 2528c7e..de836a1 100644 --- a/model/option.go +++ b/model/option.go @@ -1,9 +1,10 @@ package model import ( - "gin-template/common" "strconv" "strings" + + "gin-template/common" ) type Option struct { diff --git a/model/user.go b/model/user.go index b5dd990..6d4f1f6 100644 --- a/model/user.go +++ b/model/user.go @@ -2,8 +2,9 @@ package model import ( "errors" - "gin-template/common" "strings" + + "gin-template/common" ) // User if you add sensitive fields, don't forget to clean them in setupLogin function. diff --git a/router/api-router.go b/router/api-router.go index e43665a..e83bcfd 100644 --- a/router/api-router.go +++ b/router/api-router.go @@ -3,6 +3,7 @@ package router import ( "gin-template/controller" "gin-template/middleware" + "github.com/gin-gonic/gin" ) diff --git a/router/main.go b/router/main.go index 30b25c8..fa36541 100644 --- a/router/main.go +++ b/router/main.go @@ -2,6 +2,7 @@ package router import ( "embed" + "github.com/gin-gonic/gin" ) diff --git a/router/web-router.go b/router/web-router.go index 1cb0663..001b7f6 100644 --- a/router/web-router.go +++ b/router/web-router.go @@ -2,12 +2,14 @@ package router import ( "embed" + "net/http" + "gin-template/common" "gin-template/controller" "gin-template/middleware" + "github.com/gin-contrib/static" "github.com/gin-gonic/gin" - "net/http" ) func setWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {