formatutil.go 308 B

123456789101112131415161718
  1. package formatutil
  2. import (
  3. "math"
  4. "strings"
  5. )
  6. func Float64ToResponse(f float64) *float64 {
  7. if math.IsNaN(f) || math.IsInf(f, 0) {
  8. return nil
  9. }
  10. return &f
  11. }
  12. func StripWhitespace(s string) string {
  13. return strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(s, " ", ""), "\t", ""), "\n", "")
  14. }