2
0

Use Go 1.13 errors instead of xerrors

This commit is contained in:
Jack Christensen
2021-03-25 09:01:59 -04:00
parent aa89720576
commit dd160540c4
80 changed files with 927 additions and 956 deletions
+8 -8
View File
@@ -3,11 +3,11 @@ package pgtype
import (
"database/sql/driver"
"encoding/binary"
"fmt"
"math"
"strconv"
"github.com/jackc/pgio"
errors "golang.org/x/xerrors"
)
type Float8 struct {
@@ -50,28 +50,28 @@ func (dst *Float8) Set(src interface{}) error {
if int64(f64) == value {
*dst = Float8{Float: f64, Status: Present}
} else {
return errors.Errorf("%v cannot be exactly represented as float64", value)
return fmt.Errorf("%v cannot be exactly represented as float64", value)
}
case uint64:
f64 := float64(value)
if uint64(f64) == value {
*dst = Float8{Float: f64, Status: Present}
} else {
return errors.Errorf("%v cannot be exactly represented as float64", value)
return fmt.Errorf("%v cannot be exactly represented as float64", value)
}
case int:
f64 := float64(value)
if int(f64) == value {
*dst = Float8{Float: f64, Status: Present}
} else {
return errors.Errorf("%v cannot be exactly represented as float64", value)
return fmt.Errorf("%v cannot be exactly represented as float64", value)
}
case uint:
f64 := float64(value)
if uint(f64) == value {
*dst = Float8{Float: f64, Status: Present}
} else {
return errors.Errorf("%v cannot be exactly represented as float64", value)
return fmt.Errorf("%v cannot be exactly represented as float64", value)
}
case string:
num, err := strconv.ParseFloat(value, 64)
@@ -161,7 +161,7 @@ func (dst *Float8) Set(src interface{}) error {
if originalSrc, ok := underlyingNumberType(src); ok {
return dst.Set(originalSrc)
}
return errors.Errorf("cannot convert %v to Float8", value)
return fmt.Errorf("cannot convert %v to Float8", value)
}
return nil
@@ -204,7 +204,7 @@ func (dst *Float8) DecodeBinary(ci *ConnInfo, src []byte) error {
}
if len(src) != 8 {
return errors.Errorf("invalid length for float4: %v", len(src))
return fmt.Errorf("invalid length for float4: %v", len(src))
}
n := int64(binary.BigEndian.Uint64(src))
@@ -256,7 +256,7 @@ func (dst *Float8) Scan(src interface{}) error {
return dst.DecodeText(nil, srcCopy)
}
return errors.Errorf("cannot scan %T", src)
return fmt.Errorf("cannot scan %T", src)
}
// Value implements the database/sql/driver Valuer interface.