doule6314 2011-12-15 00:21
浏览 83
已采纳

Go是否提供REPL?

The interactive environment is VERY helpful for a programmer. However, it seems Go does not provide it. Is my understanding correct?

  • 写回答

10条回答 默认 最新

  • duan7007 2011-12-15 08:53
    关注

    No, Go does not provide a REPL.

    However, as already mentioned, Go Playground (this is the new URL) is very handy. The Go Authors are also thinking about adding a feature-rich editor to it.

    If you want something local, consider installing hsandbox. Running it simply with hsandbox go will split your terminal screen (with screen) where you can write code at the top and see its execution output at the bottom on every save.

    There was a gotry among standard Go commands, which used to evaluate expressions (with an optional package name), and could be run like gotry 1+2 and gotry fmt 'Println("hello")' from shell. It is no longer available because not many people actually used it.

    I have also seen third party projects for building a REPL for Go, but now I can only find links to two of them: igo and go-repl. How well do they work I don't know.

    My two cents: Speed of compilation makes writing a REPL possible for Go, as it has also helped building the tools mentioned here, but the same speed makes REPL less necessary. Every time I want to test something in Go that I can't run in Playground I open a simple .go file and start coding and simply run the code. This will be even easier when the go command in Go 1 makes one-command build process possible and way easier.

    UPDATE: Latest weekly release of Go added go command which can be used to very easily build a file: write your prog.go file and run go build prog.go && ./prog

    UPDATE 2: With Go 1 you can directly run go programs with go run filename.go

    UPDATE 3: gore is a new project which seems interesting.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?