HTTP Client for the xkcd API.
Details on the xkcd API can be found here.
Outside a project using go modules, get the latest version by running:
go get github.com/nishanths/go-xkcd
Inside a project using go modules, use:
go get github.com/nishanths/go-xkcd/v2
The following program prints details about xkcd.com/599:
package main
import (
"context"
"fmt"
"log"
"github.com/nishanths/go-xkcd/v2"
)
func main() {
client := xkcd.NewClient()
comic, err := client.Get(context.Background(), 599)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s: %s\n", comic.Title, comic.ImageURL) // Apocalypse: http://imgs.xkcd.com/comics/apocalypse.png
}
To run tests:
$ go test -race
https://godoc.org/github.com/nishanths/go-xkcd
The MIT License. Copyright © Nishanth Shanmugham.