Does Go provide REPL?

2019-01-08 04:12发布

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

10条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-08 04:34

Have you tried the Go Playground?

About the Go Playground

The Go Playground is a web service that runs on golang.org's servers. The service receives a Go program, compiles, links, and runs the program inside a sandbox, then returns the output.

查看更多
倾城 Initia
3楼-- · 2019-01-08 04:36

No, but you can exploit the speed of compilation (as mentioned in other answers).

Have a look at rango that uses a generate-compile-run loop to mimic a REPL. You can also start it with imports and statements to begin an interactive session.

查看更多
萌系小妹纸
4楼-- · 2019-01-08 04:38

If you're a Vim user, the vim-go plugin (https://github.com/fatih/vim-go) provides a command (GoRun) to run and print the output of the current buffer. You still have to include all the boilerplate code of a main Go file, but it still provides a convenient way to quickly test code snippets in your local environment.

enter image description here

HTH

查看更多
别忘想泡老子
5楼-- · 2019-01-08 04:41

Please also check www.gorepl.com for go REPL and other REPLs

查看更多
狗以群分
6楼-- · 2019-01-08 04:44

The GoSpeccy project includes a builtin REPL of a restricted subset of the Go language. The implementation is using goeval.

查看更多
Emotional °昔
7楼-- · 2019-01-08 04:48

Gosh is the interactive Golang shell. The goal is to provide an easy-to-use interactive execution environment.

https://github.com/mkouhei/gosh

查看更多
登录 后发表回答