Skip to content

Commit

Permalink
Trim space before parsing timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
the-maldridge committed Mar 10, 2021
1 parent 8056287 commit 3364916
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"time"
"log"
"strings"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -45,7 +46,7 @@ func doProbe(w http.ResponseWriter, r *http.Request) {
var otime float64
if c == 200 {
// If this fails it will just stay at zero; acceptable.
otime, err = strconv.ParseFloat(string(otimes), 64)
otime, err = strconv.ParseFloat(strings.TrimSpace(string(otimes)), 64)
if err != nil {
log.Println("Error parsing otime", err)
}
Expand All @@ -58,7 +59,7 @@ func doProbe(w http.ResponseWriter, r *http.Request) {
var stimeStart float64
if c == 200 {
// If this fails it will just stay at zero; acceptable.
stimeStart, err = strconv.ParseFloat(string(stimeStarts), 64)
stimeStart, err = strconv.ParseFloat(strings.TrimSpace(string(stimeStarts)), 64)
if err != nil {
log.Println("Error parsing stimeStart", err)
}
Expand All @@ -70,7 +71,7 @@ func doProbe(w http.ResponseWriter, r *http.Request) {
var stimeEnd float64
if c == 200 {
// If this fails it will just stay at zero; acceptable.
stimeEnd, err = strconv.ParseFloat(string(stimeEnds), 64)
stimeEnd, err = strconv.ParseFloat(strings.TrimSpace(string(stimeEnds)), 64)
if err != nil {
log.Println("Error parsing stimeEnd", err)
}
Expand Down

0 comments on commit 3364916

Please sign in to comment.