Lightweight unofficial Go wrapper for JokeAPI.
Basic usage:
import (
"github.com/snoo8/gojoke"
"fmt"
)
func main() {
joke, err := gojoke.Any()
if err != nil {
panic(err)
}
fmt.Println(joke)
}
Fetch any joke
gojoke.Any() // > The generation of random numbers is too important to be left to chance.
Fetch a joke safe for everyone
gojoke.Safe() // > What do you call a cow with no legs? ...
Fetch any joke in a certain language
gojoke.Language("de") // > Warst du eigentlich schonmal in Las Vegas? ...
Fetch a joke in a certain category
gojoke.Category("Pun") // > There are only 10 kinds of people in ...
gojoke.Joke (language string, category string, blacklist []string, single bool, twopart bool, safe bool) -> (joke string, error)
Advanced joke search
Argument | Description | Example |
---|---|---|
language |
The language of the joke | "en" |
category |
The category of the joke | "Pun" |
blacklist |
Blacklist flags | "religious","nsfw" |
single |
If the type of the joke can be "single" | true |
twopart |
If the type of the joke can be "twopart" | false |
safe |
If the joke must be safe for everyone | true |