diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-01 13:36:20 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-01 13:36:20 -0500 |
commit | ee4857cdd5416686e36624621b3460f1bc334c54 (patch) | |
tree | cf40832f85dccc666278fe4839486ec2e6b30f8a /internal/feed/score.go | |
parent | a40213480929a93a78239053a40a6ee93547c063 (diff) | |
download | cvez-ee4857cdd5416686e36624621b3460f1bc334c54.tar.bz2 cvez-ee4857cdd5416686e36624621b3460f1bc334c54.zip |
internal/feed: represent scores as uint8
Diffstat (limited to 'internal/feed/score.go')
-rw-r--r-- | internal/feed/score.go | 8 |
1 files changed, 4 insertions, 4 deletions
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) } |