• ubunt 20.04 有道词典命令行工具


    发现一个开源的有道词典命令行工具 go 写的:

    Github地址:https://github.com/chenjiandongx/youdao-go

    -------------------------------------------------------------------

    构建

    获取源码

    $ git clone https://github.com/chenjiandongx/youdao-go.git

    编译

    • Windows
    $ go get
    $ go build -ldflags "-s -w" -o yd.exe cli.go core.go
    • Linux/MacOS
    $ go get
    $ go build -ldflags "-s -w" -o yd cli.go core.go

    upx压缩可执行文件

    $ upx yd    # windows 则为 upx yd.exe

    使用

    $ yd --help
    yd <words> [options]
    
    Query words meanings via the command line.
    
    Example:
      words could be word or sentence.
    
      yd hello
      yd php is the best language in the world
      yd 你好
    
    Usage:
      yd <words>...
      yd -h | --help
      yd -v | --version
    
    Options:
      -h --help         show this help message and exit.
      -v  --version     displays the current version of youdao-go.
    

    查询单词

    $ yd coder
    >>  coder: 编码器
    
        美:['kəudə]  英:['kəʊdə]
    
        n. 编码器;编码员
        n. (Coder)人名;(法)科代;(英、葡)科德尔
    
        coder[编码员 编码器 程序员]
        speech coder[语言编码器 音频编码器 语音编码器]
        incremental coder[增量编码器]

    查询句子

    $ yd talk is cheap, show me the code
    >>  talk is cheap, show me the code: 说说很简单,给我代码

    中文翻译

    $ yd php是世界上最好的语言
    >>  php是世界上最好的语言: PHP is one of the best language in the world

    -------------------------------------------------------------------

    ps: 需要先安装go和upx

    1. 安装go

    sudo apt install golang-go

    安装完后设下环境变量(可以考到用户目录 .bashrc 最后面):

    export GOBIN=$GOPATH/bin

    export PATH=$PATH:$GOBIN

    2. 安装 upx 压缩go编译的程序【参考:https://www.haiyun.me/archives/1143.html】

    UPX 是一个免费且开源的可执行程序文件加壳器,支持许多不同操作系统下的可执行文件格式。【Github:https://github.com/upx/upx】

    sudo apt install upx-ucl

    3. go get时碰到error:"GnuTLS recv error (-110): The TLS connection was non-properly terminated." 

    查了半天,网上有说多执行几遍不用管,后来查看确实docopt-go已经下好了,在个人用户目录多了一个go目录。然后直接执行后面的 go build 命令也成功了,所以忽略这个错。

    参考:https://www.jianshu.com/p/b65548201927

  • 相关阅读:
    C#后台调用Delphi 的Ocx
    打包.NET程序
    Tomcat配置虚拟目录、多域名、多个Http监听端口的方式
    检测多个Jar包冲突的class
    SessionFactoryImpl.get错误:java.lang.ArrayIndexOutOfBoundsException: 68问题
    搭建内网搜索平台
    cvs update报错
    混淆和加密.NET开发工具
    CVS报错:could not find desired version问题的解决
    记录一次接口压力测试结果
  • 原文地址:https://www.cnblogs.com/xuewangkai/p/15396794.html
Copyright © 2020-2023  润新知