Warning: you need
goimports
installed.
Using go get
:
go get github.com/xrash/gonel/cmd/gonel
Manually compiling:
$ git clone https://github.com/xrash/gonel.git
$ cd gonel
$ make
$ sudo cp bin/gonel /usr/local/bin
Usage:
gonel [flags]
Flags:
-h, --help help for gonel
-i, --import stringArray package name to import
$ gonel "fmt.Println(123)"
123
$ gonel "fmt.Println(333)" "fmt.Println(999)"
333
999
$ gonel 'fmt.Println(123)
> fmt.Println(333)
> fmt.Println(999)'
123
333
999
-
You must have
goimports
installed in your machine. -
gonel
will automatically import your packages usinggoimports
, so you can write code as if you were insidemain()
with everything set up already. -
If you still need to explicitly import a package, use the flag
-i
, like this:$ gonel -i fmt -i math 'fmt.Println(math.Max(20, 30))'
. -
You can use multiple lines/pieces of code as multiple arguments, or just break lines in the same argument.
-
STDIN passed to
gonel
will be forwarded to the program, so you'll be able to access it throughos.Stdin
.