@@ -170,7 +170,12 @@ func (c *Client) Query(ctx context.Context, req QueryRequest) (*QueryResponse, e
170170 if err != nil {
171171 return nil , fmt .Errorf ("failed to send request: %w" , err )
172172 }
173- defer resp .Body .Close ()
173+ defer func () {
174+ if err := resp .Body .Close (); err != nil {
175+ // Log the error or handle it as appropriate for your application
176+ fmt .Printf ("Error closing response body: %v\n " , err )
177+ }
178+ }()
174179
175180 if resp .StatusCode != http .StatusOK {
176181 return nil , fmt .Errorf ("unexpected status code: %d" , resp .StatusCode )
@@ -204,7 +209,12 @@ func (c *Client) QueryBatch(ctx context.Context, req QueryBatchRequest) (*QueryB
204209 if err != nil {
205210 return nil , fmt .Errorf ("failed to send request: %w" , err )
206211 }
207- defer resp .Body .Close ()
212+ defer func () {
213+ if err := resp .Body .Close (); err != nil {
214+ // Log the error or handle it as appropriate for your application
215+ fmt .Printf ("Error closing response body: %v\n " , err )
216+ }
217+ }()
208218
209219 if resp .StatusCode != http .StatusOK {
210220 return nil , fmt .Errorf ("unexpected status code: %d" , resp .StatusCode )
@@ -231,7 +241,12 @@ func (c *Client) GetVulnerability(ctx context.Context, id string) (*Vulnerabilit
231241 if err != nil {
232242 return nil , fmt .Errorf ("failed to send request: %w" , err )
233243 }
234- defer resp .Body .Close ()
244+ defer func () {
245+ if err := resp .Body .Close (); err != nil {
246+ // Log the error or handle it as appropriate for your application
247+ fmt .Printf ("Error closing response body: %v\n " , err )
248+ }
249+ }()
235250
236251 if resp .StatusCode != http .StatusOK {
237252 return nil , fmt .Errorf ("unexpected status code: %d" , resp .StatusCode )
0 commit comments