func main() { url := "http://developer.hatena.ne.jp" entry, err := hbapi.GetEntryInfo(url) if err != nil { panic(err) } fmt.Printf("%#v\n", entry) }
func (api HttpAPI) RequestRelatedBookmarks(url string) []Bookmark { info, err := hbapi.GetEntryInfo(url) if err != nil { return []Bookmark{} } bookmarks := []Bookmark{} for _, bookmark := range info.Related { bookmarks = append(bookmarks, Bookmark{ Title: bookmark.Title, URL: bookmark.URL, Count: bookmark.Count, }) } return bookmarks }
func (api HttpAPI) RequestUserBookmark(url string) map[string]Bookmark { info, err := hbapi.GetEntryInfo(url) if err != nil { return map[string]Bookmark{} } ub := map[string]Bookmark{} for _, bookmark := range info.Bookmarks { ub[bookmark.User] = Bookmark{ Title: info.Entry.Title, URL: info.Entry.URL, Count: info.Entry.Count, } } return ub }