Adding Stringer interface to Objects
This commit is contained in:
parent
c3798bd94c
commit
1a028dc2b9
1 changed files with 10 additions and 1 deletions
11
imdb.go
11
imdb.go
|
@ -135,7 +135,7 @@ func GetMovieByTitle(title string, year string) (*MovieResult, error) {
|
|||
return r, nil
|
||||
}
|
||||
|
||||
// returns a MovieResult given a ImdbId ex:"tt2015381"
|
||||
// returns a MovieResult given a ImdbId ex:"tt2015381"
|
||||
func GetMovieByImdbId(id string) (*MovieResult, error) {
|
||||
resp, err := omdbApiRequest("", id, "", "")
|
||||
if err != nil {
|
||||
|
@ -187,3 +187,12 @@ func checkErrorStatus(status int) error {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//Stringer Interface for MovieResult
|
||||
func (mr MovieResult) String() string {
|
||||
return fmt.Sprintf("#%s: %s (%s)", mr.ImdbID, mr.Title, mr.Year)
|
||||
}
|
||||
|
||||
func (sr SearchResult) String() string {
|
||||
return fmt.Sprintf("#%s: %s (%s) Type: %s", sr.ImdbId, sr.Title, sr.Year, sr.Type)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue