Documentation
¶
Overview ¶
Package opinions helps finding links to discussions about given topics/URLs on social news websites.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Discussion ¶
Discussion is a representation of discussion inside social media service.
func SearchHackerNews ¶
SearchHackerNews query HN Search API for given prompt. It returns list of discussions sorted by relevance, then popularity, then number of comments.
See: https://hn.algolia.com/api
Example ¶
client := http.Client{}
query := "grugbrain.dev"
opinions := ensure.MustReturn(SearchHackerNews(context.TODO(), client, query))
fmt.Println(opinions[0])
Output: Hacker News https://news.ycombinator.com/item?id=31840331 The Grug Brained Developer https://grugbrain.dev/
func SearchLemmy ¶ added in v1.3.0
SearchLemmy query Lemmy Search API for given prompt. It returns list of discussions sorted by rank based on the score and time of the latest comment, with decay over time.
See: https://join-lemmy.org/docs/users/03-votes-and-ranking.html
Example ¶
client := http.Client{}
query := "https://grugbrain.dev/"
opinions := ensure.MustReturn(SearchLemmy(context.TODO(), client, query))
fmt.Println(opinions[0])
Output: Lemmy https://lemmy.world/post/7563451 The Grug Brained Developer (2022) https://grugbrain.dev/
func SearchLobsters ¶
SearchLobsters query Lobsters search engine for given prompt. It returns list of discussions sorted by relevance.
Example ¶
client := http.Client{}
query := "https://grugbrain.dev"
opinions := ensure.MustReturn(SearchLobsters(context.TODO(), client, query))
fmt.Println(opinions[0])
Output: Lobsters https://lobste.rs/s/ifaar4/grug_brained_developer The Grug Brained Developer https://grugbrain.dev/
func (Discussion) String ¶
func (d Discussion) String() string
String returns string representation of discussion metadata.
type HackerNewsResponse ¶
type HackerNewsResponse struct {
Hits []struct {
CreatedAt time.Time `json:"created_at"`
Title string `json:"title"`
URL string `json:"url"`
NumComments int `json:"num_comments"`
ObjectID string `json:"objectID"`
} `json:"hits"`
}
HackerNewsResponse represents some interesting fields of response from HN Search API.
type LemmyResponse ¶ added in v1.3.0
type LemmyResponse struct {
Posts []struct {
Post struct {
ID int `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
} `json:"post"`
Counts struct {
Comments int `json:"comments"`
} `json:"counts"`
} `json:"posts"`
}
LemmyResponse represents some interesting fields of response from Lemmy Search API.
See: https://join-lemmy.org/api/interfaces/SearchResponse.html
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ensure contains helpers for testable examples.
|
Package ensure contains helpers for testable examples. |
|
Package http implements cancellable REST requests with custom User-Agent.
|
Package http implements cancellable REST requests with custom User-Agent. |