From ee4857cdd5416686e36624621b3460f1bc334c54 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 1 Feb 2022 13:36:20 -0500 Subject: internal/feed: represent scores as uint8 --- internal/feed/score.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/feed/score.go') diff --git a/internal/feed/score.go b/internal/feed/score.go index 4e7da57..051522f 100644 --- a/internal/feed/score.go +++ b/internal/feed/score.go @@ -8,12 +8,12 @@ import ( ) // CVSS score -type Score float32 +type Score uint8 // Unmarshal CVSS score from JSON. func (me *Score) UnmarshalJSON(b []byte) error { // decode float, check for error - var v float32 + var v float64 if err := json.Unmarshal(b, &v); err != nil { return err } @@ -24,11 +24,11 @@ func (me *Score) UnmarshalJSON(b []byte) error { } // save result, return success - *me = Score(v) + *me = Score(uint8(math.Trunc(10.0 * v))) return nil } func (me Score) String() string { - val := math.Trunc(10.0 * float64(me)) / 10.0 + val := float64(me) / 10.0 return strconv.FormatFloat(val, 'f', 1, 64) } -- cgit v1.2.3