From 5ce5baa748d9556e3d870ab0bad828cfe8ba962c Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 8 Nov 2025 14:58:14 +0800 Subject: [PATCH] Enhance getBool function to support multiple data types - Refactored the getBool function to handle boolean values as well as int64, int, and float64 types, returning true for non-zero values. - Improved type safety and flexibility in data handling within the utility functions. --- agent/store/xun/utils.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agent/store/xun/utils.go b/agent/store/xun/utils.go index f2717123..ef6c5d7c 100644 --- a/agent/store/xun/utils.go +++ b/agent/store/xun/utils.go @@ -9,8 +9,15 @@ func getString(data map[string]interface{}, key string) string { } func getBool(data map[string]interface{}, key string) bool { - if v, ok := data[key].(bool); ok { + switch v := data[key].(type) { + case bool: return v + case int64: + return v != 0 + case int: + return v != 0 + case float64: + return v != 0 } return false }