https://github.com/x-motemen/gore
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.
https://github.com/x-motemen/gore
Last synced: about 1 month ago
JSON representation
Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.
- Host: GitHub
- URL: https://github.com/x-motemen/gore
- Owner: x-motemen
- License: mit
- Created: 2015-02-11T13:45:04.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2025-02-27T07:18:24.000Z (4 months ago)
- Last Synced: 2025-04-23T21:04:52.275Z (about 2 months ago)
- Language: Go
- Homepage:
- Size: 767 KB
- Stars: 5,319
- Watchers: 55
- Forks: 150
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - x-motemen/gore - Yet another Go REPL that works nicely. Featured with line editing, code completion, and more. (Go)
README
# gore
[](https://github.com/x-motemen/gore/actions?query=branch:main)
[](https://github.com/x-motemen/gore/blob/main/LICENSE)
[](https://github.com/x-motemen/gore/releases)### Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

(Screencast taken with [cho45/KeyCast](https://github.com/cho45/KeyCast))
## Usage
```sh
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](https://github.com/golang/tools/blob/master/gopls/README.md))
- Showing documents
- Auto-importing (`gore -autoimport`)## REPL Commands
Some functionalities are provided as commands in the REPL:
```
:import Import package
:type Print the type of expression
:print Show current source
:write [] Write out current source to file
:clear Clear the codes
:doc Show document
:help List commands
:quit Quit the session
```## Installation
The gore command requires Go tool-chains on runtime, so standalone binary is not distributed.```sh
go install github.com/x-motemen/gore/cmd/gore@latest
```Make sure `$GOPATH/bin` is in your `$PATH`.
Also recommended:
```sh
go install golang.org/x/tools/gopls@latest # for code completion
```Or you can use Docker:
```sh
docker run -it --rm ghcr.io/x-motemen/gore
```## FAQ/Caveats
- gore runs code using `go run` for each input. Every line entered is evaluated
repeatedly ([#67](https://github.com/x-motemen/gore/issues/67)),
so you can't bind the evaluated time by `time.Now()`, for example.
This implementation also makes the execution fairly slow
([#182](https://github.com/x-motemen/gore/issues/182)).
This project started from a simple idea to use `go 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](https://github.com/cosmos72/gomacro)
or [yaegi](https://github.com/containous/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 to `go 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.## License
[The MIT License](./LICENSE).
## Author
- motemen <>
- itchyny <>