From 8a1130909dddfff128e7cb8d3ca0bb6a7b0ac72a Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 27 Oct 2022 10:21:15 +0700 Subject: [PATCH] add get float64 func --- get.go | 9 ++++++++- go.mod | 1 + go.sum | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/get.go b/get.go index f224ad4..fa3e453 100644 --- a/get.go +++ b/get.go @@ -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() +} diff --git a/go.mod b/go.mod index 47ff148..b485938 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 2f5149f..0d3a426 100644 --- a/go.sum +++ b/go.sum @@ -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= -- 2.34.1