From 8af94f323d86c3cae992dc5ff4896bae52f208e8 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 9 Mar 2025 20:28:08 +0800 Subject: index: Humanize allocated size --- http_handle_index.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'http_handle_index.go') diff --git a/http_handle_index.go b/http_handle_index.go index 623c619..144e9ab 100644 --- a/http_handle_index.go +++ b/http_handle_index.go @@ -6,6 +6,8 @@ package main import ( "net/http" "runtime" + + "github.com/dustin/go-humanize" ) func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any) { @@ -22,6 +24,6 @@ func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any) // Memory currently allocated memstats := runtime.MemStats{} runtime.ReadMemStats(&memstats) - params["mem"] = memstats.Alloc + params["mem"] = humanize.IBytes(memstats.Alloc) render_template(w, "index", params) } -- cgit v1.2.3