From fa754ad6bfa9a91c83457c2f60656b62feb5484e Mon Sep 17 00:00:00 2001 From: Jarcau Stefan-Cristian Date: Sun, 31 Dec 2023 20:25:23 +0200 Subject: [PATCH] Can't keep track anymore --- helper_functions.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/helper_functions.go b/helper_functions.go index da9f137..fca1c32 100644 --- a/helper_functions.go +++ b/helper_functions.go @@ -8,6 +8,7 @@ import ( "io" "net/http" "os/exec" + "regexp" "strconv" "strings" "time" @@ -223,11 +224,11 @@ func getTotalBytes(alias []string, token string, fileSize float64) (float64, err stringBody := string(body) startIndex := strings.Index(stringBody, "minio_cluster_capacity_raw_free_bytes{server=\"127.0.0.1:9000\"}") - //pattern := "[^0-9+e\\-\\.$]" + pattern := "[^0-9+e\\-\\.$]" - //re := regexp.MustCompile(pattern) - //processedInput := re.ReplaceAllString(stringBody[startIndex+63:startIndex+63+16], " ") - processedInput := strings.Replace(stringBody[startIndex+63:startIndex+63+16], " ", "", -1) + re := regexp.MustCompile(pattern) + processedInput := re.ReplaceAllString(stringBody[startIndex+63:startIndex+63+25], " ") + processedInput = strings.Replace(processedInput, " ", "", -1) total, err := strconv.ParseFloat(processedInput, 64) fmt.Println(processedInput)