71

GitHub - motemen/gore: Yet another Go REPL that works nicely. Featured with line...

 4 years ago
source link: https://github.com/motemen/gore
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

gore Travis Build Status

Yet another Go REPL that works nicely. Featured with line editing, code completion, and more.

Screencast

(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 gocode)
  • Pretty printing (pp or spew recommended)
  • Showing documents
  • Auto-importing (gore -autoimport)

REPL Commands

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

Installation

The gore command requires Go tool-chains on runtime, so standalone binary is not distributed.

GO111MODULE=off go get -u github.com/motemen/gore/cmd/gore

Make sure $GOPATH/bin is in your $PATH.

Also recommended:

GO111MODULE=off go get -u github.com/mdempsky/gocode   # for code completion
GO111MODULE=off go get -u github.com/k0kubun/pp        # or github.com/davecgh/go-spew/spew

FAQ/Caveats

  • If you see too many arguments in call to mainScope.LookupParent while installing gore, run go get -u golang.org/x/tools/go/types.
  • gore runs code using go run for each input. If you have entered time-consuming code, gore will run it for each input and take some time.
  • To import a local package, first fetch it with go get my/package, then :import will work properly.

License

The MIT License.

Author

motemen <[email protected]>


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK