Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: better import order group #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/constants.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package common

import (
"github.com/google/uuid"
"sync"
"time"

"github.com/google/uuid"
)

var StartTime = time.Now().Unix() // unit: second
Expand Down
3 changes: 2 additions & 1 deletion common/embed-file-system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion common/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion common/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package common

import (
"fmt"
"github.com/google/uuid"
"html/template"
"log"
"net"
"os/exec"
"runtime"
"strconv"
"strings"

"github.com/google/uuid"
)

func OpenBrowser(url string) {
Expand Down
3 changes: 2 additions & 1 deletion common/verification.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package common

import (
"github.com/google/uuid"
"strings"
"sync"
"time"

"github.com/google/uuid"
)

type verificationValue struct {
Expand Down
8 changes: 5 additions & 3 deletions controller/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 5 additions & 3 deletions controller/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion controller/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions controller/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 5 additions & 3 deletions controller/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions controller/wechat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion middleware/auth.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions middleware/rate-limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions middleware/turnstile-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions model/file.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package model

import (
"os"
"path"

"gin-template/common"

_ "gorm.io/driver/sqlite"
"gorm.io/gorm"
"os"
"path"
)

type File struct {
Expand Down
4 changes: 3 additions & 1 deletion model/main.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion model/option.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package model

import (
"gin-template/common"
"strconv"
"strings"

"gin-template/common"
)

type Option struct {
Expand Down
3 changes: 2 additions & 1 deletion model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions router/api-router.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package router
import (
"gin-template/controller"
"gin-template/middleware"

"github.com/gin-gonic/gin"
)

Expand Down
1 change: 1 addition & 0 deletions router/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package router

import (
"embed"

"github.com/gin-gonic/gin"
)

Expand Down
4 changes: 3 additions & 1 deletion router/web-router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down