Skip to content

Commit

Permalink
fix : float64 nullish strconv
Browse files Browse the repository at this point in the history
  • Loading branch information
sutantodadangfit committed Jun 20, 2023
1 parent 89d8ad8 commit 891220f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions float.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package nullish
import (
"bytes"
"database/sql/driver"
"encoding/binary"
"errors"
"math"
"strconv"

"github.com/goccy/go-json"
)
Expand Down Expand Up @@ -39,8 +38,12 @@ func (nf *NullFloat) Scan(value interface{}) error {

case []byte:

bits := binary.LittleEndian.Uint64(t)
res = math.Float64frombits(bits)
f, err := strconv.ParseFloat(string(t), 64)
if err != nil {
return errors.New("type assertion []byte to float64 is failed")
}

res = f

case float64:
res = t
Expand Down

0 comments on commit 891220f

Please sign in to comment.