Skip to content
forked from shopper29/deepl-go

DeepL API client library in Go.

License

Notifications You must be signed in to change notification settings

KEINOS/go-deepl

 
 

Repository files navigation

go1.17+ Go Reference

go-deepl

go-deepl is a simple Go library for DeepL API client.

Note: It is a fork from deepl-go by shopper29 with some modifications. Such as security updates, replacing deprecated modules, code coverage, etc.

Usage

go get github.com/KEINOS/go-deepl
import "github.com/KEINOS/go-deepl/deepl"

Requirements

Examples

package main

import (
    "context"
    "fmt"

    "github.com/KEINOS/go-deepl/deepl"
)

func main() {
    // Create a client for free account of DeepL API (choices: deepl.APIFree,
    // deepl.APIPro, deepl.APICustom). The second arg is the logger. If nil,
    // the default logger is used. Which logs to stderr.
    cli, err := deepl.New(deepl.APIFree, nil)
    if err != nil {
        log.Fatal(err)
    }

    translateResponse, err := cli.TranslateSentence(
        context.Background(),
        "Hello", // Phrase to translate
        "EN",    // from English
        "JA",    // to Japanese
    )

    if err != nil {
        log.Fatal(err)
    } else {
        fmt.Printf("%+v\n", translateResponse)
    }
    // Output:
    // &{Translations:[{DetectedSourceLanguage:EN Text:こんにちは}]}
}

License and Authors

About

DeepL API client library in Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 95.7%
  • Makefile 4.3%