-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
45 lines (42 loc) · 921 Bytes
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package genderize
import (
"fmt"
)
// Simple interface with minimal configuration.
func ExampleGet() {
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:
}
// Client with custom API key and user agent, query with language and country IDs.
func ExampleClient_Get() {
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
}