From b64725f2f823479f7b84648451c448a0def0a964 Mon Sep 17 00:00:00 2001 From: yusing Date: Sun, 14 Sep 2025 00:07:56 +0800 Subject: [PATCH] refactor(stats): change uptime type from string to int64 --- internal/api/v1/stats.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/api/v1/stats.go b/internal/api/v1/stats.go index 75a917b8..78d443af 100644 --- a/internal/api/v1/stats.go +++ b/internal/api/v1/stats.go @@ -9,12 +9,11 @@ import ( "github.com/yusing/go-proxy/internal/net/gphttp/httpheaders" "github.com/yusing/go-proxy/internal/net/gphttp/websocket" "github.com/yusing/go-proxy/internal/types" - "github.com/yusing/go-proxy/internal/utils/strutils" ) type StatsResponse struct { Proxies ProxyStats `json:"proxies"` - Uptime string `json:"uptime"` + Uptime int64 `json:"uptime"` } // @name StatsResponse type ProxyStats struct { @@ -40,7 +39,7 @@ func Stats(c *gin.Context) { getStats := func() (any, error) { return map[string]any{ "proxies": cfg.Statistics(), - "uptime": strutils.FormatDuration(time.Since(startTime)), + "uptime": int64(time.Since(startTime).Round(time.Second).Seconds()), }, nil }