first commit
This commit is contained in:
18
internal/pkg/convertor/pgx.go
Normal file
18
internal/pkg/convertor/pgx.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package convertor
|
||||
|
||||
import "github.com/jackc/pgx/v5/pgtype"
|
||||
|
||||
func NumericToFloat64(num pgtype.Numeric) float64 {
|
||||
if !num.Valid {
|
||||
return 0
|
||||
}
|
||||
f1, err := num.Float64Value()
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
f2, err := f1.Value()
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return f2.(float64)
|
||||
}
|
||||
Reference in New Issue
Block a user