Skip to content

Latest commit

 

History

History
39 lines (35 loc) · 1015 Bytes

README.md

File metadata and controls

39 lines (35 loc) · 1015 Bytes

deepl-go

This library provides a simple API client function for Deepl.

Usage

  1. Install package
    > go get github.com/DaikiYamakawa/deepl-go
  2. We should register valid API key in the environment variable.
    > export DEEPL_API_KEY=xxx-xxx-xxx
  3. 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:こんにちは}]}