Skip to content

Commit

Permalink
ci: use gofumpt
Browse files Browse the repository at this point in the history
  • Loading branch information
fufuok committed Mar 17, 2024
1 parent b800611 commit 80f294b
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 41 deletions.
4 changes: 1 addition & 3 deletions cmder/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const (
cmdTimeout = 3 * time.Second
)

var (
ErrCMDTimeout = errors.New("command execution timed out")
)
var ErrCMDTimeout = errors.New("command execution timed out")

// RunCmd 运行命令, 返回结果和状态
func RunCmd(cmdArgs []string, timeout ...time.Duration) cmd.Status {
Expand Down
6 changes: 2 additions & 4 deletions common/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"github.com/fufuok/utils/xsync"
)

var (
// Funcs 通用函数集合, 用于远程配置获取等场景
Funcs = xsync.NewMapOf[string, Func]()
)
// Funcs 通用函数集合, 用于远程配置获取等场景
var Funcs = xsync.NewMapOf[string, Func]()

type Func func(args any) error
6 changes: 2 additions & 4 deletions common/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import (

// !!! 注意: 先执行 InitRedisDB(...) 初始化后再使用下面的方法

var (
// RedisDB Redis 连接
RedisDB redis.UniversalClient
)
// RedisDB Redis 连接
var RedisDB redis.UniversalClient

// InitRedisDB 指定已初始化的 *redis.Client
func InitRedisDB(rdb redis.UniversalClient) {
Expand Down
4 changes: 2 additions & 2 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,6 @@ func initDefaultConfig() {
}

func makePaths() {
_ = os.MkdirAll(LogPath, 0755)
_ = os.MkdirAll(ConfigPath, 0755)
_ = os.MkdirAll(LogPath, 0o755)
_ = os.MkdirAll(ConfigPath, 0o755)
}
4 changes: 1 addition & 3 deletions config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"github.com/joho/godotenv"
)

var (
ExtraEnvFiles []string
)
var ExtraEnvFiles []string

// 读取 .env 配置
// 后加载的优先, 已存在的环境变量值会被覆盖
Expand Down
6 changes: 2 additions & 4 deletions config/procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ import (
"github.com/fufuok/utils"
)

var (
// DefaultGOMAXPROCS 缺省的并发配置, 最少 4
DefaultGOMAXPROCS = utils.MaxInt(runtime.NumCPU(), 4)
)
// DefaultGOMAXPROCS 缺省的并发配置, 最少 4
var DefaultGOMAXPROCS = utils.MaxInt(runtime.NumCPU(), 4)
2 changes: 1 addition & 1 deletion config/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GetDataSource(args any) error {
md5Old := xhash.MustMD5Sum(params.Conf.Path)
md5New := xhash.MD5Hex(body)
if md5New != md5Old {
if err = os.WriteFile(params.Conf.Path, []byte(body), 0600); err != nil {
if err = os.WriteFile(params.Conf.Path, []byte(body), 0o600); err != nil {
return err
}
}
Expand Down
6 changes: 2 additions & 4 deletions crontab/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import (
"github.com/fufuok/pkg/logger"
)

var (
// 定时任务调度器
crontab *cron.Cron
)
// 定时任务调度器
var crontab *cron.Cron

type M struct{}

Expand Down
16 changes: 9 additions & 7 deletions master/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ var (
remotePipelines []ContextFunc
)

type Stage int
type ContextFunc func(ctx context.Context)
type Pipeline interface {
Start() error
Runtime() error
Stop() error
}
type (
Stage int
ContextFunc func(ctx context.Context)
Pipeline interface {
Start() error
Runtime() error
Stop() error
}
)

func Register(stage Stage, sf ...Pipeline) {
mu.Lock()
Expand Down
4 changes: 1 addition & 3 deletions web/fiber/engine/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
"github.com/fufuok/pkg/web/fiber/response"
)

var (
app *fiber.App
)
var app *fiber.App

type App func(app *fiber.App) *fiber.App

Expand Down
4 changes: 1 addition & 3 deletions web/fiber/response/exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const (
defaultErrMsg = "错误的请求"
)

var (
apiSuccessNil = json.MustJSON(APISuccessNilData())
)
var apiSuccessNil = json.MustJSON(APISuccessNilData())

// APIException 通用异常处理
func APIException(c *fiber.Ctx, code int, msg string, data any) error {
Expand Down
4 changes: 1 addition & 3 deletions web/gin/engine/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
"github.com/fufuok/pkg/web/gin/middleware"
)

var (
app *gin.Engine
)
var app *gin.Engine

type App func(app *gin.Engine) *gin.Engine

Expand Down

0 comments on commit 80f294b

Please sign in to comment.