File tree 2 files changed +5
-5
lines changed
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -97,11 +97,11 @@ func (c *cache) Update(client Client) error {
97
97
},
98
98
)
99
99
}
100
-
101
100
f , err := os .Create (c .path )
102
101
if err != nil {
103
102
return err
104
103
}
104
+ defer func () { _ = f .Close () }()
105
105
enc := json .NewEncoder (f )
106
106
enc .SetIndent ("" , "\t " )
107
107
err = enc .Encode (questions )
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ type decoder struct {
41
41
42
42
var debugResponse = false
43
43
44
- func (g decoder ) Decode (resp * http.Response , v interface {}) error {
44
+ func (d decoder ) Decode (resp * http.Response , v interface {}) error {
45
45
data , _ := io .ReadAll (resp .Body )
46
46
if debugResponse {
47
47
fmt .Println (string (data ))
@@ -50,10 +50,10 @@ func (g decoder) Decode(resp *http.Response, v interface{}) error {
50
50
ele := reflect .ValueOf (v ).Elem ()
51
51
switch ty .Elem () {
52
52
case reflect .TypeOf (gjson.Result {}):
53
- if g .path == "" {
53
+ if d .path == "" {
54
54
ele .Set (reflect .ValueOf (gjson .ParseBytes (data )))
55
55
} else {
56
- ele .Set (reflect .ValueOf (gjson .GetBytes (data , g .path )))
56
+ ele .Set (reflect .ValueOf (gjson .GetBytes (data , d .path )))
57
57
}
58
58
case reflect .TypeOf ([]byte {}):
59
59
ele .SetBytes (data )
@@ -62,7 +62,7 @@ func (g decoder) Decode(resp *http.Response, v interface{}) error {
62
62
}
63
63
return nil
64
64
}
65
-
65
+
66
66
type ErrorResp struct {
67
67
Errors string `json:"errors"`
68
68
}
You can’t perform that action at this time.
0 commit comments