xkcd

package module
v0.0.0-...-55b8d50 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 6 Imported by: 0

README

xkcd - XKCD library for Go

Example usage

package main

import (
	"fmt"
	"log"

	"github.com/1nter-p/xkcd"
)

func main() {
	// Get the comic with number 327 (Exploits of a Mom/"Bobby Tables")
	c, err := xkcd.ComicFromNum(327)
	if err != nil {
		log.Fatal(err)
	}

	// Print the title and alt text
	fmt.Println("Title:", c.Title)
	fmt.Println(c.Alt)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comic

type Comic struct {
	Number     int    `json:"num"`
	Title      string `json:"title"`
	SafeTitle  string `json:"safe_title"`
	Alt        string `json:"alt"`
	ImageURL   string `json:"img"`
	Link       string `json:"link"`
	News       string `json:"news"`
	Transcript string `json:"transcript"`
	Year       string `json:"year"`
	Month      string `json:"month"`
	Day        string `json:"day"`
}

func ComicFromNum

func ComicFromNum(num int) (Comic, error)

ComicFromNum creates a new Comic from the given comic number/ID.

func ComicFromURL

func ComicFromURL(url string) (Comic, error)

ComicFromURL creates a new Comic from the given comic URL (info.0.json).

func LatestComic

func LatestComic() (Comic, error)

LatestComic returns the latest comic as a Comic object.

func RandomComic

func RandomComic() (Comic, error)

RandomComic returns a random comic as a Comic object.

Jump to

Keyboard shortcuts

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