Merge pull request #1 from darknesto/master
Properly closing response body
This commit is contained in:
commit
4e9f9dc017
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 {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
r := new(SearchResponse)
|
||||
err = json.NewDecoder(resp.Body).Decode(r)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -123,9 +125,11 @@ func GetMovieByTitle(title string, year string) (*MovieResult, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
r := new(MovieResult)
|
||||
err = json.NewDecoder(resp.Body).Decode(r)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -141,9 +145,11 @@ func GetMovieByImdbId(id string) (*MovieResult, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
r := new(MovieResult)
|
||||
err = json.NewDecoder(resp.Body).Decode(r)
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue