4 ms·
Off-topic: I know one of you smart folks here at HN have figured out how to do something similar to go playground in the terminal that makes it easy to write a
by gizdan 5y ago
Off-topic: I know one of you smart folks here at HN have figured out how to do something similar to go playground in the terminal that makes it easy to write a script, and on safe it go fmt's + imports, and then runs it. Something with vim + tmux or whatever. If this is you, I'd love it if you could share it!
- stonewareslord 5y agoI use a script for this. Something like: #!/usr/bin/env bash { find . -name "*.go" -print echo package.json } | entr bash -c ' set -euxo pipefail clear go fmt clear go build : ' You can make it fancier like adding cd into "${BASH_SOURCE[0]%/*}", etc
- chakkepolja 5y agoThere's an REPL called yaegi, but it's pretty primitive (no autocompletion etc.. when I tried). There seems to be another interpreter that seems to be able to provide some autocomplete using some other third party tool, but it seemed to run from beginning every time (same effect as `go run`) and I havent tried it.
- gizdan 5y agoThe issue with these REPLs is for whatever reason it doesn't come close to the experience of say the python REPL. I have been hoping for the Go devs to build a REPL into the tooling but so far nothing has happened yet.
- chakkepolja 5y agoYeah they are very primitive :(
- gobookdev 5y agoI made this extension for VS Code that also saves the outputs to markdown, so you can save it straight to blog posts: https://marketplace.visualstudio.com/items?itemName=gobookdev.gobook https://marketplace.visualstudio.com/items?itemName=gobookde... Each cell runs in a 0.3 secs on Linux, but 3 seconds + on Windows. If you want just straight terminal check out Gomacro, that's a interpreter that runs really fast, didn't find any differences to compiled Go.