This library provides a simple API client function for Deepl.
- Install package
> go get github.com/DaikiYamakawa/deepl-go
- We should register valid API key in the environment variable.
> export DEEPL_API_KEY=xxx-xxx-xxx
- We can call deepl library in our code.
package main import ( "context" "fmt" "github.com/DaikiYamakawa/deepl-go" ) func main() { cli, err := deepl.New("https://api.deepl.com", nil) if err != nil { fmt.Printf("Failed to create client:\n %+v\n", err) } translateResponse, err := cli.TranslateSentence(context.Background(), "Hello", "EN", "JA") if err != nil { fmt.Printf("Failed to translate text:\n %+v\n", err) } else { fmt.Printf("%+v\n", translateResponse) } }
&{Translations:[{DetectedSourceLanguage:EN Text:こんにちは}]}