Skip to content

Commit

Permalink
Change set value of StatusCode using reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
haritsfahreza committed Aug 2, 2018
1 parent 66dac4d commit f2ac4da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"log"
"net/http"
"os"
"reflect"
"strconv"
"time"
)

Expand Down Expand Up @@ -106,7 +108,7 @@ func (c *Client) ExecuteRequest(req *http.Request, v interface{}) error {
if err = json.Unmarshal(resBody, v); err != nil {
return err
}
v.(map[string]interface{})["status_code"] = string(res.StatusCode)
reflect.ValueOf(v).Elem().FieldByName("StatusCode").SetString(strconv.Itoa(res.StatusCode))
}

return nil
Expand Down

0 comments on commit f2ac4da

Please sign in to comment.