(Screencast taken with cho45/KeyCast)
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.
- 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
)
Some functionalities are provided as commands in the REPL:
:import <package path> 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
:help List commands
:quit Quit the session
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
Make sure $GOPATH/bin
is in your $PATH
.
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
- gore runs code using
go run
for 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 run
for 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 get
to check the usage of a remote repository,:import github.com/...
will automatically download that module. Also, you don't need togo get
the 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.
- motemen <[email protected]>
- itchyny <[email protected]>