by Rapzid · 12y ago · 0 comments
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?
Still plenty of room for improvement, but there are people who are excited about making GopherJS fun to work with.
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.