项目
在 GitHub 查看
x-motemen/gore
关于
一款好用的 Go REPL,支持行编辑、代码补全等功能。
其他项目可以做什么
- Line editing with history
- Multi-line input
- Package importing with completion
- Evaluates any expressions, statements and function declarations
实测星标增长
- 24小时
- +1
- 7天
- +2
- 15天
- +1
- 1个月
- 0
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文gore
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

(Screencast taken with cho45/KeyCast)
Usage
gore
After a prompt is shown, enter any Go expressions/statements/functions or commands described below.
To quit the session, type Ctrl-D or use :q command.
Features
- Line editing with history
- Multi-line input
- Package importing with completion
- Evaluates any expressions, statements and function declarations
- No "evaluated but not used" errors
- Code completion (requires gopls)
- Showing documents
- Auto-importing (
gore -autoimport)
REPL Commands
Some functionalities are provided as commands in the REPL:
:import [<alias>] <package> Import package
:type <expr> Print the type of expression
:print Show current source
:write [<filename>] Write out current source to file
:clear Clear the codes
:doc <expr or pkg> Show document
:verbose [on|off] Toggle printing of assigned or declared values
:help List commands
:quit Quit the session
Environment Variables
GORE_HOME: directory for the command history file. Defaults to$XDG_DATA_HOME/gore, or~/.goreifXDG_DATA_HOMEis unset.GORE_PAGER: pager command used to display:docoutput (e.g.less). If unset, documents are printed directly.GORE_VERBOSE: set to a boolean false value (0orfalse) to suppress automatic printing of assigned or declared values at startup. Defaults to on; toggle during a session with:verbosecommand.
Installation
The gore command requires Go tool-chains on runtime, so standalone binary is not distributed.
go install github.com/x-motemen/gore/cmd/gore@latest
Also recommended:
go install golang.org/x/tools/gopls@latest # for code completion
Or you can use Docker:
docker run -it --rm ghcr.io/x-motemen/gore
FAQ/Caveats
- gore runs code using
go runfor each input. Every line entered is evaluated repeatedly (#67), so you can't bind the evaluated time bytime.Now(), for example. This implementation also makes the execution fairly slow (#182). This project started from a simple idea to usego runfor all REPL input. I think this project has provided some value for Go users, but these days there are other REPL implementations that are more actively maintained and run faster. I recommend using gomacro or yaegi. - gore support Go modules. You can load local modules when you start gore at
the project directory. You don't need to
go getto check the usage of a remote repository,:import github.com/...will automatically download that module. Also, you don't need togo getthe pretty print module anymore. If you want to load a local code from$GOPATH, you need to create the modules file (go mod init ...) and then start gore at the project directory.
License
Author
- motemen <[email protected]>
- itchyny <[email protected]>
探索相关项目
加载中…