2015-02-24

State of Go REPL (February 2015)

REPL is one thing that quite important to test simple snippet, useful to make sure that a part of code would work as expected. Previously I have tried go-repl, go-eval, rango, but none of them enjoyable to use.

One of the promising one is go-fish, with limited import option, you can install it using these commands:

go get -u -v github.com/rocky/go-types
go get -u -v github.com/rocky/go-loader
go get -u -v github.com/rocky/go-fish
go build make_env.go
make
mv go-fish $GOPATH/bin

One thing that annoys me is no history (Up/Down key) and limited set of import (that can be added), but I haven't found a way to import package on runtime.


Another one that quite promising is gore, to install it use run these commands:

# workaround for moved astutil repository
mkdir $GOPATH/src/golang.org/x/tools/go/ast
ln -s $GOPATH/src/golang.org/x/tools/astutil $GOPATH/src/golang.org/x/tools/go/ast

go get -u -v github.com/nsf/gocode
go get -u -v github.com/k0kubun/pp 
go get -u -v github.com/davecgh/go-spew

go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/motemen/gore

Gore is one that works fine, to import package use colon, import and package name without quote, for example:

:import fmt

You can also use Tab key for auto complete, Up/Down key to see typed commands, Ctrl+D for canceling last command, but you cannot erase 1 previous word using Alt+Backspace. I think this program has the less annoyance than other alternatives.