Skip to content

Commit

Permalink
🧹 Rename strict
Browse files Browse the repository at this point in the history
  • Loading branch information
Omochice committed Sep 28, 2021
1 parent 4073271 commit cbb5db2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ type Setting struct {
TargetLang string `json:"target_lang"`
}

type Response struct {
Translations []Translation
type DeepLResponse struct {
Translations []Translated
}

type Translation struct {
type Translated struct {
DetectedSourceLaguage string `json:"detected_source_language"`
Text string `json:"text"`
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func Translate(Text string, setting Setting) ([]string, error) {

translateResponse, err := ParseResponse(resp)
if err != nil {
return []string{}, err
return results, err
}
for _, translated := range translateResponse.Translations {
results = append(results, translated.Text)
Expand All @@ -164,8 +164,8 @@ func Translate(Text string, setting Setting) ([]string, error) {
return results, err
}

func ParseResponse(resp *http.Response) (Response, error) {
var responseJson Response
func ParseResponse(resp *http.Response) (DeepLResponse, error) {
var responseJson DeepLResponse
body, err := ioutil.ReadAll(resp.Body)

if err != nil {
Expand Down

0 comments on commit cbb5db2

Please sign in to comment.