This is a creation in Article, where the information may have evolved or changed.
Bret Victor's inventing on principle is one of the most exciting and shocking demos I have ever seen. Although the former Apple UI Daniel made the presentation early in 2012, his influence has not diminished, and any change in the process of writing a program should produce feedback directly, allowing the ape to see the results, or the creators needing real-time feedback on what they create .
Python has been used before, very much like Ipythonn Notebook, using Ipython Notenook to quickly complete a number of prototypes is very convenient. Now that the project needs to start using the go language, I'm thinking, is there a ipython environment where go can be used? There is also a related post, but the above did not give a valid answer.
I did a little homework, the result is not perfect, here to share to everyone.
Official version Go Playground
The best resource to start learning the Go language is the official tour, where you can learn to run the Go sample program and get the results straight away. Perfect embodiment of inventing on principle concept.
This tour incorporates a go playgound, where you can find the code for the project on GitHub.
The project contains a front end and a containerized background sandbox to ensure the security of the program's operation.
However, go playground has some limitations:
- Cannot import user-defined packages
- Editor weak, no syntax highlighting, no hint, no undo ...
- There's no ipython that segmented interaction
Version Xiam go Playground
Xiam's go playground has made significant improvements on the basis of the official playground. Including:
- Support for user-defined packages
- Support unsafe sandbox, user can access network, file system, etc.
- The container of the front end
To use a custom package, you need to modify the dockerfile of the sandbox.
FROM xiam/go-playground/unsafeboxRUN go get github.com/myuser/mypackageRUN go get github.com/otheruser/otherpackageENTRYPOINT ["/go/bin/sandbox"]
Then rebuild the container's image as well.
Although we solved the problem of custom packages, the editor is still too weak and lacks ipython segmented interaction. Is there any better?
Gophernotes
Jupyter's notebook can actually support different language kernels, and the Gophernotes project provides the kernel of the Go language for Jupyter.
The project is inspired by Gore, an IGO-based core, that is not already being maintained.
The above is a test I use gophernotes, when I run a loop, if written a line, in[7], everything OK. But when I write three lines, in[8], I can't output the correct results.
The errors given in the background are:
Error running goimports:/tmp/979860191/func_proxy.go:4:4: expected declaration, found 'for'[I 08:18:56.621 NotebookApp] Saving file at /Untitled.ipynb
I did not understand why, reported a bug, if there is a understanding of the small partner please tell me.
At this point, although did not find a good, but I have great hope for the gophernotes, I hope it can solve some basic problems at an early date.