Adding Stringer interface to Objects

This commit is contained in:
Christopher Herrera 2014-09-21 16:50:45 -04:00
parent c3798bd94c
commit 1a028dc2b9

11
imdb.go
View file

@ -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)
}