feat: 添加勇者指令和字符串格式化工具
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-03-24 02:59:06 +08:00
committed by cnb
parent 52db89b390
commit 75de7bd557
2 changed files with 53 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"math/rand/v2"
"strings"
"time"
"github.com/gogf/gf/v2/os/gtime"
@@ -167,3 +168,12 @@ func IsCurrentTimeInRange(startStr, endStr string) (bool, error) {
// 3. 比较当前时间是否在 [startToday, endToday] 区间内
return now.After(startToday) && now.Before(endToday), nil
}
// Format 把 args 按顺序填入 {0},{1},{2}...
func Format(s string, args ...interface{}) string {
for i, arg := range args {
placeholder := "{" + string(rune('0'+i)) + "}"
s = strings.ReplaceAll(s, placeholder, gconv.String(arg))
}
return s
}