进入交互式命令行界面

huangapple go评论88阅读模式
英文:

Go interactive shell

问题

有人知道是否有一个 REPL(交互式的 Go shell,类似于 irb)可用于 Go,允许用户使用 import 语句吗?我想能够像这样做:

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

我尝试过 igo,但似乎还不支持这个功能。

英文:

> Possible Duplicate:
> Does Go provide REPL?

<!-- End of automatically inserted text -->

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 ( 
             &quot;log&quot;
             &quot;mypackage/pkg&quot;
            )
log.Print(&quot;hello, world!&quot;)
pkg.Print(&quot;Hello&quot;)
...

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

答案1

得分: 10

go-eval这个库是由与igo相同的作者开发的。

它是对旧的exp/eval包的改进。

然而,由于缺少符号,我无法导入包,这可能是igo不支持import语句的原因。

最好选择像play.golang.org上看到的编译/执行软件。

英文:

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.

huangapple
  • 本文由 发表于 2012年9月27日 18:43:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/12619564.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定