go-libs/helper/anyToString.go

16 lines
243 B
Go
Raw Permalink Normal View History

2025-03-18 20:13:24 +01:00
package helper
import "fmt"
func AnyToString(value interface{}) string {
switch v := value.(type) {
case string:
return v
case float64:
return fmt.Sprintf("%.2f", v)
case int:
return fmt.Sprintf("%d", v)
default:
return ""
}
}