This is an unofficial Go SDK for using the DeepL API.
go get github.com/EYERCORD/deepl-sdk-go
package main
import (
"context"
"fmt"
"os"
"github.com/michimani/deepl-sdk-go"
"github.com/michimani/deepl-sdk-go/params"
"github.com/michimani/deepl-sdk-go/types"
)
func main() {
client, err := deepl.NewClient()
if err != nil {
fmt.Println(err)
return
}
text := []string{
"Привіт",
"Це приклад тексту",
}
params := ¶ms.TranslateTextParams{
TargetLang: types.TargetLangEN,
Text: text,
}
res, errRes, err := c.TranslateText(context.TODO(), params)
if err != nil {
fmt.Println(err)
}
if errRes != nil {
fmt.Println("ErrorResponse", errRes.Message)
}
for i := range res.Translations {
fmt.Printf("%s -> %s\n", text[i], res.Translations[i].Text)
}
}