Parcourir la source

Merge pull request #2220 from opencost/niko/fmtutil

Add utility to strip whitespace
Niko Kovacevic il y a 2 ans
Parent
commit
ceefb70cc8
1 fichiers modifiés avec 8 ajouts et 1 suppressions
  1. 8 1
      pkg/util/formatutil/formatutil.go

+ 8 - 1
pkg/util/formatutil/formatutil.go

@@ -1,6 +1,9 @@
 package formatutil
 
-import "math"
+import (
+	"math"
+	"strings"
+)
 
 func Float64ToResponse(f float64) *float64 {
 	if math.IsNaN(f) || math.IsInf(f, 0) {
@@ -9,3 +12,7 @@ func Float64ToResponse(f float64) *float64 {
 
 	return &f
 }
+
+func StripWhitespace(s string) string {
+	return strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(s, " ", ""), "\t", ""), "\n", "")
+}