31

Possible Duplicate:
Does Go provide REPL?

Does anyone know if there is an REPL (interactive go shell, similar to irb) available for go which allows the user to use import statements? I'd like to be able to do something like this:

$igo import ( 
             "log"
             "mypackage/pkg"
            )
log.Print("hello, world!")
pkg.Print("Hello")
...

I've tried igo but that doesn't seem to support this yet.

Community
  • 1
  • 1
Kenny Grant
  • 9,360
  • 2
  • 33
  • 47
  • take a look at this question http://stackoverflow.com/questions/8513609/does-go-provide-repl – Mairbek Khadikov Sep 27 '12 at 11:31
  • Thanks, I'm looking for something local rather than in the browser though so that I can have a local console which deals with imports properly (as this does, but this is online). Perhaps I'll just have to gather input with something like igo and use go run on a temporary file. Would rather not have a dependency on hsandbox as want to put this in a go package. – Kenny Grant Sep 27 '12 at 11:43
  • Id be really happy if Go had shell like Haskell or Ruby does. It allows for quick prototyping, or just a really awesome playground. Sometimes I'm just too lazy to write and compile programs to play with small things...lets hope for such tool/feature in future versions of go. – if __name__ is None Aug 11 '13 at 20:13

1 Answers1

10

There is go-eval from the same author as igo.

It's an improvement on the old exp/eval package.

However, I was not able to import packages due to missing symbols, which is probably the reason for igo not supporting the import statement.

It's probably the best to go with compile/execute software as seen on play.golang.org.

nemo
  • 55,207
  • 13
  • 135
  • 135