@@ -16,26 +16,29 @@ type Float4 struct {
1616 Valid bool
1717}
1818
19- // ScanFloat64 implements the Float64Scanner interface.
19+ // ScanFloat64 implements the [ Float64Scanner] interface.
2020func (f * Float4 ) ScanFloat64 (n Float8 ) error {
2121 * f = Float4 {Float32 : float32 (n .Float64 ), Valid : n .Valid }
2222 return nil
2323}
2424
25+ // Float64Value implements the [Float64Valuer] interface.
2526func (f Float4 ) Float64Value () (Float8 , error ) {
2627 return Float8 {Float64 : float64 (f .Float32 ), Valid : f .Valid }, nil
2728}
2829
30+ // ScanInt64 implements the [Int64Scanner] interface.
2931func (f * Float4 ) ScanInt64 (n Int8 ) error {
3032 * f = Float4 {Float32 : float32 (n .Int64 ), Valid : n .Valid }
3133 return nil
3234}
3335
36+ // Int64Value implements the [Int64Valuer] interface.
3437func (f Float4 ) Int64Value () (Int8 , error ) {
3538 return Int8 {Int64 : int64 (f .Float32 ), Valid : f .Valid }, nil
3639}
3740
38- // Scan implements the database/sql Scanner interface.
41+ // Scan implements the [ database/sql. Scanner] interface.
3942func (f * Float4 ) Scan (src any ) error {
4043 if src == nil {
4144 * f = Float4 {}
@@ -58,21 +61,23 @@ func (f *Float4) Scan(src any) error {
5861 return fmt .Errorf ("cannot scan %T" , src )
5962}
6063
61- // Value implements the database/sql/driver Valuer interface.
64+ // Value implements the [ database/sql/driver. Valuer] interface.
6265func (f Float4 ) Value () (driver.Value , error ) {
6366 if ! f .Valid {
6467 return nil , nil
6568 }
6669 return float64 (f .Float32 ), nil
6770}
6871
72+ // MarshalJSON implements the [encoding/json.Marshaler] interface.
6973func (f Float4 ) MarshalJSON () ([]byte , error ) {
7074 if ! f .Valid {
7175 return []byte ("null" ), nil
7276 }
7377 return json .Marshal (f .Float32 )
7478}
7579
80+ // UnmarshalJSON implements the [encoding/json.Unmarshaler] interface.
7681func (f * Float4 ) UnmarshalJSON (b []byte ) error {
7782 var n * float32
7883 err := json .Unmarshal (b , & n )
0 commit comments