Skip to content

nishanths/go-xkcd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-xkcd

HTTP Client for the xkcd API.

wercker status Coverage Status GoDoc

https://xkcd.com/1481/

Details on the xkcd API can be found here.

Install

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

Example

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
}

Test

To run tests:

$ go test -race

Godoc

https://godoc.org/github.com/nishanths/go-xkcd

License

The MIT License. Copyright © Nishanth Shanmugham.