Documentation
¶
Index ¶
- type Client
- func (c *Client) AskStories(ctx context.Context) ([]int, error)
- func (c *Client) BestStories(ctx context.Context) ([]int, error)
- func (c *Client) GetItem(ctx context.Context, id int) (Item, error)
- func (c *Client) GetUser(ctx context.Context, id string) (User, error)
- func (c *Client) JobStories(ctx context.Context) ([]int, error)
- func (c *Client) MaxItemID(ctx context.Context) (int, error)
- func (c *Client) NewStories(ctx context.Context) ([]int, error)
- func (c *Client) ShowStories(ctx context.Context) ([]int, error)
- func (c *Client) TopStories(ctx context.Context) ([]int, error)
- func (c *Client) Updates(ctx context.Context) (*Updates, error)
- type HTTPError
- type Item
- type Option
- type Updates
- type User
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AskStories ¶
AskStories returns up to 200 of the latest ask stories.
func (*Client) BestStories ¶
BestStories returns up to 500 of the best stories.
func (*Client) GetUser ¶
Example ¶
package main import ( "context" "fmt" "log" "github.com/hermanschaaf/hackernews" ) func main() { client := hackernews.NewClient() // Get the karma for user "pg" and print true if it's greater than 10000. ctx := context.Background() user, err := client.GetUser(ctx, "pg") if err != nil { log.Fatal(err) } fmt.Println(user.Karma > 10000) }
Output: true
func (*Client) JobStories ¶
JobStories returns up to 200 of the latest job stories.
func (*Client) NewStories ¶
NewStories returns up to 500 of the newest stories.
func (*Client) ShowStories ¶
ShowStories returns up to 200 of the latest show stories.
func (*Client) TopStories ¶
TopStories returns up to 500 of the latest top stories.
type Item ¶
type Item struct { ID int `json:"id"` Deleted bool `json:"deleted"` Type string `json:"type"` By string `json:"by"` Time int `json:"time"` Text string `json:"text"` Dead bool `json:"dead"` Parent int `json:"parent"` Kids []int `json:"kids"` URL string `json:"url"` Score int `json:"score"` Title string `json:"title"` Parts []int `json:"parts"` Descendants int `json:"descendants"` }
Click to show internal directories.
Click to hide internal directories.