Go interactive shell [duplicate]
Asked Answered
P

1

32

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.

Perpetrate answered 27/9, 2012 at 10:43 Comment(3)
take a look at this question https://mcmap.net/q/108166/-does-go-provide-a-replDewclaw
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.Perpetrate
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.Ulises
F
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.

Firecure answered 27/9, 2012 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.