27 lines
562 B
Go
27 lines
562 B
Go
package lib
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestTranslate(t *testing.T) {
|
|
baidu := &BaiduFanyi{
|
|
AppId: "20220708001267795",
|
|
AppSec: "5nYOaQUPol0gYL51wujB",
|
|
}
|
|
res, err := baidu.Translate("hello", "en", "zh")
|
|
log.Print(res, err)
|
|
time.Sleep(1 * time.Second)
|
|
res, err = baidu.Translate("taoshihan", "en", "zh")
|
|
log.Print(res, err)
|
|
time.Sleep(1 * time.Second)
|
|
res, err = baidu.Translate("can i help you", "en", "zh")
|
|
log.Print(res, err)
|
|
|
|
time.Sleep(1 * time.Second)
|
|
res, err = baidu.Translate("你好", "zh", "en")
|
|
log.Print(res, err)
|
|
}
|