Documentation ¶
Overview ¶
Package genderize provides a client for the Genderize.io web service.
Index ¶
Examples ¶
Constants ¶
const ( Male = "male" Female = "female" Unknown = "" )
Gender string constants.
const Version = "0.2.0"
Version of this library. Used to form the default user agent string.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the Genderize API.
func (*Client) Get ¶
Get gender info for names with optional country and language IDs.
Example ¶
Client with custom API key and user agent, query with language and country IDs.
client, err := NewClient(Config{ UserAgent: "GoGenderizeDocs/0.0", // Note that you'll need to use your own API key. APIKey: "", }) if err != nil { panic(err) } responses, err := client.Get(Query{ Names: []string{"Kim"}, CountryID: "dk", LanguageID: "da", }) if err != nil { panic(err) } for _, response := range responses { fmt.Printf("%s: %s\n", response.Name, response.Gender) }
Output: Kim: male
type RateLimit ¶
type RateLimit struct { // The number of names allotted for the current time window. Limit int64 // The number of names left in the current time window. Remaining int64 // Seconds remaining until a new time window opens. Reset int64 }
RateLimit holds info on API quotas from rate limit headers. See https://genderize.io/#rate-limiting for details.
type Response ¶
type Response struct { Name string // Gender can be "male", "female", or empty, // in which case Probability and Count should be ignored. Gender string Probability float64 Count int64 }
A Response is a name with gender and probability information attached.
func Get ¶
Get gender info for names, using the default client and country/language IDs.
Example ¶
Simple interface with minimal configuration.
responses, err := Get([]string{"James", "Eva", "Thunderhorse"}) if err != nil { panic(err) } for _, response := range responses { fmt.Printf("%s: %s\n", response.Name, response.Gender) }
Output: James: male Eva: female Thunderhorse:
type ServerError ¶
A ServerError contains a message from the Genderize API server.
func (ServerError) Error ¶
func (serverError ServerError) Error() string
Error returns the error message.