Skip to content

Simple golang wrapper for chuck norris jokes API

Notifications You must be signed in to change notification settings

Keda87/chucknorrisgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

chuck-norris-go

Golang wrapper for "The Internet Chuck Norris Database" http://www.icndb.com/api/

Installation:

$ go get github.com/Keda87/chucknorrisgo

Example usage:

import (
	"fmt"
	"github.com/Keda87/chucknorrisgo"	
) 


cn := &chucknorrisgo.ChuckNorris{}

// Build the payload.
joke := cn.Build()
joke := cn.FirstName("John").Build()                                          // Change main name character.
joke := cn.FirstName("John").LastName("Doe").Build()                          // Change main name character.
category := []string{"nerdy", "explicit"}
joke := cn.FirstName("John").LastName("Doe").Categories(category...).Build()  // Filter jokes by categories.

// Fetch the jokes.
result := joke.Random()  // Get the jokes randomly.
result := joke.Get(128)  // Get the jokes by specific ID.

fmt.Println(result.JokeID)
fmt.Println(result.JokeText)