Official golang wrapper for Sv443's jokeapi.
Install-
go get -u github.com/icelain/jokeapi
Basic Usage Without Parameters-
import "github.com/icelain/jokeapi"
func main(){
api, err := jokeapi.New()
if err != nil {
panic(err)
}
response := 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, err := jokeapi.New()
if err != nil {
panic(err)
}
api.SetParams(&ctgs, &blacklist, &jt)
response := api.Fetch()
}
Usage without all parameters(requires other params to be declared as nil)-
api.SetParams(&ctgs,nil, nil)
Or-
api.SetBlacklist(&blacklist)
api.SetCategory(&ctgs)
api.SetType(&joketype)