v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-28 05:20:12 -07:00

update README

This commit is contained in:
eeeXun 2022-10-17 22:49:23 +08:00
parent 98addc58c5
commit d31dd1346b
2 changed files with 8 additions and 4 deletions

View File

@ -17,3 +17,7 @@ https://translate.googleapis.com/translate_a/single?client=gtx&sl=%s&tl=%s&dt=t&
[beep](https://github.com/faiface/beep)
[example](https://gist.github.com/iochen/acad285d2d23066df9449d40a7f3547c)
## config
[viper](https://github.com/spf13/viper)

View File

@ -30,16 +30,16 @@ func (t Translator) Translate(message string) (string, error) {
)
res, err := http.Get(url_str)
if err != nil {
return err.Error(), err
return "", err
}
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return err.Error(), err
return "", err
}
err = json.Unmarshal(body, &data)
if err != nil {
return err.Error(), err
return "", err
}
if len(data) > 0 {
@ -50,5 +50,5 @@ func (t Translator) Translate(message string) (string, error) {
}
return translated, nil
}
return "Translation not found", errors.New("Translation not found")
return "", errors.New("Translation not found")
}