4 ms·
Is there any hope for a workflow similar to clojurescripts? It's very nice to have your page hooked to the repl and be able to re-evaluate pieces of code then
by Rapzid 12y ago
Is there any hope for a workflow similar to clojurescripts? It's very nice to have your page hooked to the repl and be able to re-evaluate pieces of code then have the page functionality change without constant refreshes and recompiles.
Edit: I want to expand on this a bit. I'm curious about how the workflow is now and what's envisioned. Things like the above mentioned and also LightTables insta-repl make for great workflow value propositions. I very much like Clojure, but I like Go as well and have written much, much more of it. So this is very interesting, but.. Do I need to write the Go code blind, then compile to js, then refresh and test my page to see what's going on?
- ajhager 12y agoThere is no repl, but there are projects in development that make the workflow less of a chore. My own project, SRVi (https://github.com/ajhager/srvi https://github.com/ajhager/srvi), serves up your GopherJS project, recompiling and embedding when you refresh the page. It will even report compiler errors right in the browser. Still plenty of room for improvement, but there are people who are excited about making GopherJS fun to work with.
- shurcooL 12y agoI've written convenience http handlers that compile Go to js on demand (and report errors in the browser console & server stderr). I do something like this in the backend: http.Handle("/assets/script.go.js", gopherjs_http.GoFiles("./assets/script.go")) Then my html files (or templates that generate html via html/template package) include it with: <script src="./assets/script.go.js" type="text/javascript"></script>. That way, I can edit the ./assets/script.go file in my code editor (with goimports on save, autocomplete, etc.) with the server running. Whenever I refresh the page in the browser, new compiled JavaScript is loaded. It's really nice to be able edit the Go script, css, html template and not need to restart the web server for effects to take place. Just refresh the page, and see new code running. That's my workflow so far. I have plans to improve that code so that it accesses the assets via a virtual file system interface, so that it's possible to have a debug version that hot-reloads all files from disk, and a release version that embeds the assets into the Go binary so it can run anywhere.
- Rapzid 12y agoVery interesting, so It's sort of a repl server. Using node.js you could even execute and return the results.. I'm starting to see how someone(who knows what they are doing) could create a POC LightTable plugin...