From 4d858f378d8af0ff4389a7b909510ac520c4e38a Mon Sep 17 00:00:00 2001 From: Enrico204 Date: Sun, 15 Nov 2020 18:05:32 +0100 Subject: [PATCH] Decode big integers using Number and not float64 in error messages --- util.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util.go b/util.go index 281c532..a07020a 100644 --- a/util.go +++ b/util.go @@ -6,7 +6,7 @@ import ( "log" "net/http" "strconv" - + "bytes" "github.com/pkg/errors" ) @@ -57,7 +57,10 @@ func extractOk(data []byte) error { Description string `json:"description"` Parameters map[string]interface{} `json:"parameters"` } - err := json.Unmarshal(data, &tgramApiError) + jdecoder := json.NewDecoder(bytes.NewReader(data)) + jdecoder.UseNumber() + + err := jdecoder.Decode(&tgramApiError) if err != nil { //return errors.Wrap(err, "can't parse JSON reply, the Telegram server is mibehaving") // FIXME / TODO: in this case the error might be at HTTP level, or the content is not JSON (eg. image?)