Properly closing response body
This commit is contained in:
parent
10fc92c08d
commit
f447044b4d
1 changed files with 6 additions and 0 deletions
6
imdb.go
6
imdb.go
|
@ -104,9 +104,11 @@ func SearchMovies(title string, year string) (*SearchResponse, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
r := new(SearchResponse)
|
r := new(SearchResponse)
|
||||||
err = json.NewDecoder(resp.Body).Decode(r)
|
err = json.NewDecoder(resp.Body).Decode(r)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -123,9 +125,11 @@ func GetMovieByTitle(title string, year string) (*MovieResult, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
r := new(MovieResult)
|
r := new(MovieResult)
|
||||||
err = json.NewDecoder(resp.Body).Decode(r)
|
err = json.NewDecoder(resp.Body).Decode(r)
|
||||||
|
defer resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -141,9 +145,11 @@ func GetMovieByImdbId(id string) (*MovieResult, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
r := new(MovieResult)
|
r := new(MovieResult)
|
||||||
err = json.NewDecoder(resp.Body).Decode(r)
|
err = json.NewDecoder(resp.Body).Decode(r)
|
||||||
|
defer resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue