Popularity
2.5
Growing
Activity
0.0
Stable
40
3
3

Programming language: Go
Tags: Third-party APIs    

go-xkcd alternatives and similar packages

Based on the "Third-party APIs" category

Do you think we are missing an alternative of go-xkcd or a related project?

Add another 'Third-party APIs' Package

README

go-xkcd

xkcd API client for Golang.

wercker status Coverage Status GoDoc

Details on the xkcd API can be found here.

Install

$ go get github.com/nishanths/go-xkcd

Import the package using github.com/nishanths/go-xkcd and refer to it as xkcd.

Each major version has a separate branch. If you need a specific version, please clone the branch instead.

Example

The following program prints details about xkcd.com/599:

package main

import (
    "fmt"
    "log"

    "github.com/nishanths/go-xkcd"
)

func main() {
    client := xkcd.NewClient()
    comic, err := client.Get(599)

    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("%s: %s", comic.Title, comic.ImageURL) // Apocalypse: http://imgs.xkcd.com/comics/apocalypse.png
}

Test

To run tests:

$ go test

Documentation

View Go Doc online.

To view go docs locally, after installing the package run:

$ godoc -http=:6060

Then visit http://localhost:6060/pkg/github.com/nishanths/go-xkcd/ in your browser.

Methods

The following methods are available on the client. All the methods return (Comic, error).

  • Latest()
  • Get(number int)
  • Random()
  • RandomInRange(begin, end, latest int)

The fields available on Comic are:

type Comic struct {
    Alt         string
    PublishDate time.Time
    ImageURL    string
    URL         string
    News        string
    Number      int
    SafeTitle   string
    Title       string
    Transcript  string
}

Contributing

Pull requests and issues are welcome!

To create a new pull request:

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request on GitHub

License

The MIT License. Copyright © Nishanth Shanmugham.


*Note that all licence references and agreements mentioned in the go-xkcd README section above are relevant to that project's source code only.