Skip to content

Commit

Permalink
Refactoring variables and lint issues (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
deydebaditya committed Nov 1, 2024
1 parent b820daf commit d4b0bc0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/server/utils/redisCmdAdapter.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package utils

import (
bytes_ext "bytes"
"bytes"
"encoding/base64"
"encoding/json"
"errors"
Expand Down Expand Up @@ -257,11 +257,9 @@ func isBase64Encoded(s string) bool {

func unmarshalRequestBody(data []byte, v *map[string]interface{}) error {

Check failure on line 258 in internal/server/utils/redisCmdAdapter.go

View workflow job for this annotation

GitHub Actions / lint

ptrToRefParam: consider `v' to be of non-pointer type (gocritic)
var rawMap map[string]interface{}

if err := json.Unmarshal(data, &rawMap); err != nil {
return err
}

for key, val := range rawMap {
switch val := val.(type) {
case float64:
Expand Down Expand Up @@ -299,13 +297,12 @@ func unmarshalRequestBody(data []byte, v *map[string]interface{}) error {
}
}

bytes, err := json.Marshal(rawMap)
jsonBytes, err := json.Marshal(rawMap)
if err != nil {
return err
}

decoder := json.NewDecoder(bytes_ext.NewReader(bytes))
decoder := json.NewDecoder(bytes.NewReader(jsonBytes))
decoder.UseNumber() // Ensures all numbers are kept as json.Number
return decoder.Decode(&v)

}

0 comments on commit d4b0bc0

Please sign in to comment.