Go wrapper for Dog CEO API
This library provides a connection to Dog CEO API. It will initialize an interface with different methods to interact with the API.
Note: This product uses the Dog CEO API but is not endorsed or certified by it.
go get https://github.com/Barbeek/go-dogceo
New() DogCEO: set the api URL and returns a DogCEO interface
The methods provided for the interface are :
ListBreeds() (*MessageMap, error): returns all dog's breeds and their subbreedsRandomImage() (*Message, error): returns a single random image from all dog collectionRandomImages(numberOfImages string) (*MessageArray, error): returns, randomly, the number of images passed in parameter from all dog collectionImagesByBreed(breed string) (*MessageArray, error): returns an array of all the images from a breedRandomImageByBreed(breed string) (*Message, error): returns a random dog image from a breedRandomImagesByBreed(breed, numberOfImages string) (*MessageArray, error): returns, randomly, the number of images passed in parameter from a breedListSubBreeds(breed string) (*MessageArray, error): returns an array of all the sub-breeds from a breedImagesBySubBreed(breed, subbreed string) (*MessageArray, error): returns an array of all the images from the sub-breedRandomImageBySubBreed(breed, subbreed string) (*Message, error): returns a random dog image from a breed's sub-bread.RandomImagesBySubBreed(breed, subbreed, numberOfImages string) (*MessageArray, error): returns, randomly, the number of images passed in parameter from a breed's sub-breed
Import the library
import "https://github.com/Barbeek/go-dogceo"
Create an instance of DogCEO interface
dogCEO, err := dogceo.New()
Call the API methods as you want.
Exemple, to get images url by bread
breeds, err := dogCEO.ListBreeds()
if err != nil {
return err
}
for key, _ := range breeds.Message {
images, err := dogCEO.ImagesByBreed(key)
if err != nil {
return err
}
}
You can run unit tests by executing command make test and linter with make lint
Enjoy!