修复无法格式化输出bool的问题

This commit is contained in:
2025-08-14 20:26:33 +08:00
parent 55c80024c2
commit 90a722b99f

View File

@@ -57,10 +57,14 @@ func ExtractJsonFieldKeyValues(msg proto.Message, paths []string, needToSnakeCas
v := rft.Get(fd)
switch v.Interface().(type) {
case int32, int64, uint32, uint64, float32, float64, bool:
case bool:
keyValues = append(keyValues, fmt.Sprintf("%t", v.Interface()))
case int32, int64, uint32, uint64, float32, float64:
keyValues = append(keyValues, fmt.Sprintf("%d", v.Interface()))
case string:
keyValues = append(keyValues, fmt.Sprintf("'%s'", v.Interface()))
default:
keyValues = append(keyValues, fmt.Sprintf("%v", v.Interface()))
}
}