-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguage.go
32 lines (28 loc) · 834 Bytes
/
language.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
package go5e
type Language struct {
Id string `json:"_id"`
Index string `json:"index"`
Name string `json:"name"`
Type string `json:"type"`
TypicalSpeakers []string `json:"typical_speakers"`
Script string `json:"script"`
Url string `json:"url"`
}
func GetLanguage(index string) (Language, error) {
var ret Language
err := doRequestAndUnmarshal("languages/"+index, &ret)
if err != nil {
return ret, err
}
return ret, nil
}
func GetLanguageByUrl(url string) (Language, error) {
var ret Language
err := doRequestRawAndUnmarshal(url, ret)
return ret, err
}
func SearchLanguageByName(query string) (NamedAPIResourceList, error) {
var ret NamedAPIResourceList
err := doRequestAndUnmarshal("languages/?name="+query, &ret)
return ret, err
}