add get float64 func

This commit is contained in:
Sinh 2022-10-27 10:21:15 +07:00
parent bfd60c8faa
commit 8a1130909d
3 changed files with 11 additions and 2 deletions

9
get.go
View File

@ -1,8 +1,10 @@
package postgresql
import (
"github.com/volatiletech/null/v8"
"time"
"github.com/shopspring/decimal"
"github.com/volatiletech/null/v8"
)
func GetString(val null.String) string {
@ -39,3 +41,8 @@ func GetJSON(val null.JSON) (res []byte) {
}
return val.JSON
}
// GetFloat64 ...
func GetFloat64(val decimal.Decimal) float64 {
return val.InexactFloat64()
}

1
go.mod
View File

@ -7,6 +7,7 @@ require (
github.com/Masterminds/squirrel v1.5.0
github.com/golang-migrate/migrate/v4 v4.15.2
github.com/jackc/pgx/v4 v4.17.0
github.com/shopspring/decimal v1.3.1
github.com/volatiletech/null/v8 v8.1.2
github.com/volatiletech/sqlboiler/v4 v4.12.0
go.uber.org/zap v1.23.0 // indirect

3
go.sum
View File

@ -1062,8 +1062,9 @@ github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvW
github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=