feat: add backend_v1 migration
Some checks failed
build quyun / Build (push) Has been cancelled

This commit is contained in:
2025-12-19 14:46:58 +08:00
parent 218eb4689c
commit 24bd161df9
119 changed files with 12259 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package utils
import (
"bufio"
"io"
)
// NewLogBuffer creates a buffer that can be used to capture output stream
// and write to a logger in real time
func NewLogBuffer(output func(string)) io.Writer {
reader, writer := io.Pipe()
go func() {
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
output(scanner.Text())
}
}()
return writer
}
// NewCombinedBuffer combines multiple io.Writers
func NewCombinedBuffer(writers ...io.Writer) io.Writer {
return io.MultiWriter(writers...)
}

View File

@@ -0,0 +1,44 @@
package utils
import "fmt"
// 构建信息变量,通过 ldflags 在构建时注入
var (
// Version 应用版本信息
Version string
// BuildAt 构建时间
BuildAt string
// GitHash Git 提交哈希
GitHash string
)
// GetBuildInfo 获取构建信息
func GetBuildInfo() map[string]string {
return map[string]string{
"version": Version,
"buildAt": BuildAt,
"gitHash": GitHash,
}
}
// PrintBuildInfo 打印构建信息
func PrintBuildInfo(appName string) {
buildInfo := GetBuildInfo()
println("========================================")
printf("🚀 %s\n", appName)
println("========================================")
printf("📋 Version: %s\n", buildInfo["version"])
printf("🕐 Build Time: %s\n", buildInfo["buildAt"])
printf("🔗 Git Hash: %s\n", buildInfo["gitHash"])
println("========================================")
println("🌟 Application is starting...")
println()
}
// 为了避免导入 fmt 包,我们使用内置的 print 和 printf 函数
func printf(format string, args ...interface{}) {
print(fmt.Sprintf(format, args...))
}