Skip to content

Commit

Permalink
feat(import): resort import
Browse files Browse the repository at this point in the history
  • Loading branch information
morehao committed Nov 30, 2024
1 parent c42e08a commit d415561
Show file tree
Hide file tree
Showing 30 changed files with 61 additions and 46 deletions.
1 change: 1 addition & 0 deletions codeGen/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package codeGen
import (
"database/sql"
"fmt"

"gorm.io/gorm"
)

Expand Down
3 changes: 2 additions & 1 deletion codeGen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package codeGen

import (
"fmt"
"strings"

"github.com/morehao/go-tools/gutils"
"gorm.io/gorm"
"strings"
)

type Generator interface {
Expand Down
5 changes: 3 additions & 2 deletions codeGen/gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package codeGen

import (
"fmt"
"os"
"testing"

"github.com/stretchr/testify/assert"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"os"
"testing"
)

func TestGenModuleCode(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions codeGen/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package codeGen

import (
"fmt"

"github.com/morehao/go-tools/gutils"
"gorm.io/gorm"
)
Expand Down
5 changes: 3 additions & 2 deletions codeGen/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package codeGen

import (
"fmt"
"github.com/morehao/go-tools/gast"
"github.com/morehao/go-tools/gutils"
"os"
"strings"
"text/template"

"github.com/morehao/go-tools/gast"
"github.com/morehao/go-tools/gutils"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package conf

import (
"fmt"
"gopkg.in/yaml.v3"
"os"

"gopkg.in/yaml.v3"
)

func LoadConfig(filepath string, dest interface{}) {
Expand Down
3 changes: 2 additions & 1 deletion dbClient/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package dbClient

import (
"fmt"
"time"

"gorm.io/driver/mysql"
"gorm.io/gorm"
"time"
)

type MysqlConfig struct {
Expand Down
3 changes: 2 additions & 1 deletion dbClient/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package dbClient

import (
"context"
"testing"

"github.com/morehao/go-tools/glog"
"github.com/morehao/go-tools/gutils"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"testing"
)

func TestInitMysql(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion dbClient/orm_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/morehao/go-tools/glog"
"go.uber.org/zap"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/utils"
"time"
)

type ormLogger struct {
Expand Down
7 changes: 4 additions & 3 deletions dbClient/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package dbClient
import (
"context"
"fmt"
"github.com/morehao/go-tools/glog"
"github.com/redis/go-redis/v9"
"go.uber.org/zap"
"net"
"strings"
"time"

"github.com/morehao/go-tools/glog"
"github.com/redis/go-redis/v9"
"go.uber.org/zap"
)

type RedisConfig struct {
Expand Down
3 changes: 2 additions & 1 deletion dbClient/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package dbClient

import (
"context"
"testing"

"github.com/morehao/go-tools/glog"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"testing"
)

func TestInitRedis(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion gast/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package gast

import (
"bytes"
"github.com/stretchr/testify/assert"
"go/parser"
"go/printer"
"go/token"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func TestParseFile(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion gast/generator_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package gast

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestAddMethodToInterfaceInFile(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions gast/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gast

import (
"fmt"

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

Expand Down
12 changes: 0 additions & 12 deletions gcli/cmd/generate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type CodeGen struct {
}

type ModuleConfig struct {
TplDir string `yaml:"tpl_dir"` // 模板目录
InternalAppRootDir string `yaml:"internal_app_root_dir"` // 项目内当前项目的根目录,如internal/genCode
ProjectRootDir string `yaml:"project_root_dir"` // 项目根目录,如go-gin-web
Description string `yaml:"description"` // 描述
Expand All @@ -32,7 +31,6 @@ type ModuleConfig struct {
}

type ModelConfig struct {
TplDir string `yaml:"tpl_dir"` // 模板目录
InternalAppRootDir string `yaml:"internal_app_root_dir"` // 项目内当前项目的根目录,如internal/genCode
ProjectRootDir string `yaml:"project_root_dir"` // import目录前缀
Description string `yaml:"description"` // 描述
Expand All @@ -41,7 +39,6 @@ type ModelConfig struct {
}

type ApiConfig struct {
TplDir string `yaml:"tpl_dir"` // 模板目录
InternalAppRootDir string `yaml:"internal_app_root_dir"` // 项目内当前项目的根目录,如internal/genCode
ProjectRootDir string `yaml:"project_root_dir"` // import目录前缀
Description string `yaml:"description"` // 描述
Expand All @@ -55,12 +52,3 @@ type ApiConfig struct {
ApiPrefix string `yaml:"api_prefix"` // api前缀
ApiSuffix string `yaml:"api_suffix"` // api后缀
}

const (
ModeModule = "module"
ModeModel = "model"
ModeApi = "api"

HttpMethodGET = "GET"
HttpMethodPOST = "POST"
)
2 changes: 1 addition & 1 deletion gcli/cmd/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var Cmd = &cobra.Command{
// 初始化配置和 MySQL 客户端
if cfg == nil {
workDir, _ := os.Getwd()
configFilepath := filepath.Join(workDir, "config", "config_generate.yaml")
configFilepath := filepath.Join(workDir, "config", "config.yaml")
conf.LoadConfig(configFilepath, &cfg)
}

Expand Down
3 changes: 2 additions & 1 deletion gcontext/ginRender/render.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package ginRender

import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/morehao/go-tools/gcontext"
"github.com/morehao/go-tools/gerror"
"github.com/pkg/errors"
"net/http"
)

func Success(ctx *gin.Context, data any) {
Expand Down
1 change: 1 addition & 0 deletions gerror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gerror

import (
"fmt"

"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion glog/zap_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package glog
import (
"context"
"fmt"
"go.uber.org/zap/buffer"
"io"
"os"
"path"
"strings"
"time"

"go.uber.org/zap"
"go.uber.org/zap/buffer"
"go.uber.org/zap/zapcore"
)

Expand Down
7 changes: 4 additions & 3 deletions glog/zap_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package glog

import (
"context"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"regexp"
"strings"
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

func TestLogger(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion gutils/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package gutils
import (
"container/list"
"fmt"
jsoniter "github.com/json-iterator/go"
"reflect"
"strconv"

jsoniter "github.com/json-iterator/go"
)

func ToJsonString(v any) string {
Expand Down
3 changes: 2 additions & 1 deletion gutils/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package gutils

import (
"container/list"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestLinkedListToArray(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion jwtAuth/claims.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package jwtAuth

import (
"github.com/golang-jwt/jwt/v5"
"time"

"github.com/golang-jwt/jwt/v5"
)

// Claims 包含注册的 claims 和自定义的 claims
Expand Down
3 changes: 2 additions & 1 deletion jwtAuth/claims_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package jwtAuth

import (
"github.com/morehao/go-tools/gutils"
"testing"
"time"

"github.com/morehao/go-tools/gutils"
)

func TestNewClaims(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion jwtAuth/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package jwtAuth
import (
"errors"
"fmt"
"github.com/golang-jwt/jwt/v5"
"reflect"
"time"

"github.com/golang-jwt/jwt/v5"
)

func CreateToken(signKey string, claims *Claims) (string, error) {
Expand Down
5 changes: 3 additions & 2 deletions jwtAuth/token_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package jwtAuth

import (
"testing"
"time"

"github.com/golang-jwt/jwt/v5"
"github.com/morehao/go-tools/gutils"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestCreateToken(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion rateLimit/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package rateLimit

import (
"github.com/redis/go-redis/v9"
"time"

"github.com/redis/go-redis/v9"
)

type Config struct {
Expand Down
3 changes: 2 additions & 1 deletion rateLimit/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package rateLimit
import (
"context"
"errors"
"github.com/go-redis/redis_rate/v10"
"time"

"github.com/go-redis/redis_rate/v10"
)

type Limiter interface {
Expand Down
5 changes: 3 additions & 2 deletions rateLimit/limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package rateLimit
import (
"context"
"fmt"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
"testing"
"time"

"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
)

func TestAllow(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions rateLimit/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package rateLimit
import (
"context"
"errors"
"github.com/go-redis/redis_rate/v10"
"github.com/redis/go-redis/v9"
"sync"
"sync/atomic"
"time"

"github.com/go-redis/redis_rate/v10"
"github.com/redis/go-redis/v9"
)

const pingInterval = time.Millisecond * 100
Expand Down

0 comments on commit d415561

Please sign in to comment.