lolly/main.go
xfy 56c6ba3731 chore(build): 添加 Makefile 构建脚本和程序入口
- Makefile: 跨平台构建、测试、代码质量检查命令
- main.go: 程序入口,支持版本信息注入

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-02 13:23:54 +08:00

34 lines
642 B
Go

package main
import (
"fmt"
"os"
)
// 通过 -ldflags 注入的版本信息
var (
version = "dev"
gitCommit = "unknown"
gitBranch = "unknown"
buildTime = "unknown"
goVersion = "unknown"
buildPlatform = "unknown"
)
func main() {
if len(os.Args) > 1 && os.Args[1] == "-v" || os.Args[1] == "--version" {
printVersion()
return
}
fmt.Println("Hello World!")
}
func printVersion() {
fmt.Printf("lolly version %s\n", version)
fmt.Printf(" Git: %s (%s)\n", gitCommit, gitBranch)
fmt.Printf(" Built: %s\n", buildTime)
fmt.Printf(" Go: %s\n", goVersion)
fmt.Printf(" Platform: %s\n", buildPlatform)
}