data

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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 NewClient

func NewClient() *Client

func (*Client) Fetch

func (c *Client) Fetch(num int) (*Comic, error)

Fetch comic by given number If 0 is passed, retrieves latest comic.

func (*Client) FetchAll

func (c *Client) FetchAll() ([]byte, error)

Fetch all comics latest concurrently. This does not guarantee that comics will be in order.

type Comic

type Comic struct {
	Title       string `json:"title"`
	Number      int    `json:"num"`
	Alt         string `json:"alt,omitempty"`
	Transcript  string `json:"transcript,omitempty"`
	ImgUrl      string `json:"img_url"`
	Explanation string `json:"explanation"`
	Date        int64  `json:"date"`
}

Combined useful data from both sources

func NewComic

func NewComic(x Xkcd, e ExplainXkcd) (*Comic, error)

type ExplainXkcd

type ExplainXkcd struct {
	Explanation string `json:"explanation"`
}

data from explainxkcd.com

type Xkcd

type Xkcd struct {
	Title      string `json:"title"`
	SafeTitle  string `json:"safe_title,omitempty"`
	Number     int    `json:"num"`
	Alt        string `json:"alt,omitempty"`
	ImgUrl     string `json:"img"`
	Transcript string `json:"transcript,omitempty"`
	Day        string `json:"day"`
	Month      string `json:"month"`
	Year       string `json:"year"`
}

data from xkcd.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL