Official golang wrapper for Sv443's jokeapi.
Install-
Add github.com/icelain/jokeapi
to your go.mod(recommended) or:
EXPORT GO11MODULE=off
go get -u github.com/icelain/jokeapi
Basic Usage Without Parameters-
import "github.com/icelain/jokeapi"
func main(){
api := jokeapi.New()
response, err := api.Fetch()
}
Response Struct-
type JokesResp struct{
Error bool
Category string
JokeType string
Joke []string
Flags map[string] bool
Id float64
Lang string
}
Usage with all parameters-
import "github.com/icelain/jokeapi"
func main(){
jt := "single"
blacklist := []string{"nsfw"}
ctgs := []string{"Programming","Dark"}
api:= jokeapi.New()
api.Set(jokeapi.Params{Blacklist: blacklist, JokeType: jt, Categories: ctgs})
response, err := api.Fetch()
}
Config struct-
api.Set(jokeapi.Params{})
Config methods-
api.SetBlacklist(blacklist)
api.SetCategories(ctgs)
api.SetJokeType(joketype)
api.SetLang(language)