Files
lunar-mini/server/internal/handler/version.go
T
gouki daebda22ee
Publish Mini Program Dev Version / publish (push) Failing after 1m38s
Build and Deploy Server / build (push) Failing after 3s
fix(wish-tree): 图片扩展名改为 .jpg
- 实际格式是 JPEG,扩展名从 .png 改为 .jpg
- 大小 332KB,远低于微信 2M 限制
2026-08-08 17:14:30 +00:00

43 lines
860 B
Go

package handler
import (
"net/http"
"os"
"github.com/gin-gonic/gin"
)
// VersionInfo 版本信息
type VersionInfo struct {
Version string `json:"version"`
BuildTime string `json:"buildTime"`
CommitSha string `json:"commitSha"`
GoVersion string `json:"goVersion"`
}
// GetVersion 获取服务器版本信息
func GetVersion(c *gin.Context) {
// 从环境变量读取版本信息(由 CI 构建时注入)
version := os.Getenv("APP_VERSION")
if version == "" {
version = "dev"
}
buildTime := os.Getenv("APP_BUILD_TIME")
if buildTime == "" {
buildTime = "unknown"
}
commitSha := os.Getenv("APP_COMMIT_SHA")
if commitSha == "" {
commitSha = "unknown"
}
c.JSON(http.StatusOK, VersionInfo{
Version: version,
BuildTime: buildTime,
CommitSha: commitSha,
GoVersion: "go1.22", // 可以通过 runtime.Version() 获取
})
}