From 7f499012a6ca4eefc0c3436e6879da796d988efd Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Sun, 13 Nov 2022 12:15:25 -0500 Subject: [PATCH] just use json.Number --- internal/common/types.go | 10 ---------- pkg/auth/session.go | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/internal/common/types.go b/internal/common/types.go index d427abd..bf16320 100644 --- a/internal/common/types.go +++ b/internal/common/types.go @@ -4,7 +4,6 @@ package common import ( "fmt" - "strconv" "strings" "time" ) @@ -13,17 +12,8 @@ type ( // PyTimeStamp is a python-style long nano timestamp PyTimestamp time.Time - // KeepZero is a special float that keeps the trailing zero on marshal - KeepZero float64 ) -func (f KeepZero) MarshalJSON() ([]byte, error) { - if float64(f) == float64(int(f)) { - return []byte(strconv.FormatFloat(float64(f), 'f', 1, 32)), nil - } - return []byte(strconv.FormatFloat(float64(f), 'f', -1, 32)), nil -} - const PytTimeFormat = "2006-01-02T15:04:05.999999-07:00" func (t *PyTimestamp) MarshalJSON() ([]byte, error) { diff --git a/pkg/auth/session.go b/pkg/auth/session.go index fd047e5..05ee3c3 100644 --- a/pkg/auth/session.go +++ b/pkg/auth/session.go @@ -25,7 +25,7 @@ type RefreshToken struct { ClientIcon *string `json:"client_icon"` TokenType TokenType `json:"token_type"` CreatedAt *common.PyTimestamp `json:"created_at"` - AccessTokenExpiration common.KeepZero `json:"access_token_expiration"` + AccessTokenExpiration json.Number `json:"access_token_expiration"` Token string `json:"token"` JWTKey string `json:"jwt_key"` LastUsedAt *common.PyTimestamp `json:"last_used_at"`