Documentation
¶
Overview ¶
Package xkcd provides a HTTP client for the xkcd.com JSON API.
Example:
c := xkcd.NewClient()
comic, err := c.Latest(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", comic)
All methods on Client are safe to use concurrently.
More details on the xkcd API can be found at https://xkcd.com/json.html.
Index ¶
Constants ¶
View Source
const BaseURL = "https://xkcd.com"
BaseURL is the default base URL for the xkcd JSON API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func NewClient ¶
func NewClient() *Client
NewClient constructs a client using http.DefaultClient and the default base URL. The returned client is ready for use.
type Comic ¶
type Comic struct {
Alt string
Day int
ImageURL string
URL string
Month int
News string
Number int
SafeTitle string
Title string
Transcript string
Year int
}
Comic contains information about an xkcd comic.
type StatusError ¶
type StatusError struct {
Code int
}
StatusError is returned when a bad response status code is received from the API.
func (StatusError) Error ¶
func (e StatusError) Error() string
Click to show internal directories.
Click to hide internal directories.
