用Go编写一个命令行字典(同义词库)应用程序

网友投稿 810 2022-10-26

用Go编写一个命令行字典(同义词库)应用程序

用Go编写一个命令行字典(同义词库)应用程序

define

A command-line dictionary (thesaurus) app, with access to multiple sources, written in Go.

Install

Pre-compiled binaries are available on the releases page.

If you have a working Go environment, you can install via go get:

go get github.com/Rican7/define

Configuration

The define app allows configuration through multiple means. You can either set configuration via:

Command line flags (good for one-off use)A configuration file (good for your "dotfiles")Environment variables (especially useful for API keys)

Command line flags

The list of command line flags is easily discovered via the --help flag. Any passed command line flag will take precedence over any other configuration mechanism.

Configuration file

A configuration file can be stored at ~/.define.conf.json and define will automatically load the values specified there.

To print the default values of the configuration, simply use the --print-config flag. This can also be used to initialize a configuration file, for example:

define --print-config > ~/.define.conf.json

Environment variables

Some configuration values can also be specified via environment variables. This is especially useful for API keys of different sources.

The following environment variables are read by define's sources:

MERRIAM_WEBSTER_DICTIONARY_APP_KEYOXFORD_DICTIONARY_APP_IDOXFORD_DICTIONARY_APP_KEY

Sources

The define app has access to multiple sources, however some of them require user-specific API keys, due to usage limitations.

A preferred source can be specified with the command line flag --preferred-source="..." or in a configuration file. For more information, see the section on Configuration.

Obtaining API keys

The following are links to register for API keys for the different sources:

Merriam-Webster's Dictionary APIOxford Dictionaries API

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:vs2019 jsoncpp 编译
下一篇:vs2019集成vcpkg
相关文章

 发表评论

暂时没有评论,来抢沙发吧~