The interactive environment is VERY helpful for a programmer. However, it seems Go does not provide it. Is my understanding correct?
The interactive environment is VERY helpful for a programmer. However, it seems Go does
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, Go does not provide a REPL(read–eval–print loop).
However, as already mentioned, Go Playground 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 gowill split your terminal screen (withscreen) where you can write code at the top and see its execution output at the bottom on every save.There was a
gotryamong standard Go commands, which used to evaluate expressions (with an optional package name), and could be run likegotry 1+2andgotry 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
.gofile and start coding and simply run the code. This will be even easier when thegocommand in Go 1 makes one-command build process possible and way easier.UPDATE: Latest weekly release of Go added
gocommand which can be used to very easily build a file: write yourprog.gofile and rungo build prog.go && ./progUPDATE 2: With Go 1 you can directly run go programs with
go run filename.goUPDATE 3:
goreis a new project which seems interesting.