3 ms·
I've been using it for some time and it's really hard to believe how it just works for so many things. https://gopherjs.github.com/playground/ https://gopherjs
by shurcooL 12y ago
I've been using it for some time and it's really hard to believe how it just works for so many things.
https://gopherjs.github.com/playground/ https://gopherjs.github.com/playground/ - GopherJS Playground.
(It compiles Go code to JavaScript in your browser using the GopherJS compiler itself compiled to JavaScript. There is no backend being used.)
https://godoc.org/honnef.co/go/js/dom https://godoc.org/honnef.co/go/js/dom - DOM bindings.
https://godoc.org/honnef.co/go/js/xhr https://godoc.org/honnef.co/go/js/xhr - XHR bindings.
- danesparza 12y agoI'm genuinely curious to know what you've been using it for.
- shurcooL 12y agoMultiple things. - Making my Markdown Format package for Atom have zero external dependencies by compiling the Go code into JavaScript. That way there's no need to install and point to the markdownfmt binary, making install easier. https://github.com/shurcooL/atom-markdown-format/commit/6b5f21c4457309f8eba3a78b82e0c9a458ff13b4 https://github.com/shurcooL/atom-markdown-format/commit/6b5f... - Replacing JavaScript with Go code in Go Package Store, still a WIP PR because I need to figure out a `go get` difficulty, but aside from that it works perfectly well. https://github.com/shurcooL/Go-Package-Store/pull/18 https://github.com/shurcooL/Go-Package-Store/pull/18 - Various experimental things that run in the browser and perform operations that use existing Go code. For example: https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/live-markdown/live-markdown.html https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/... https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/live-go-printer/live-go-printer.html https://dl.dropboxusercontent.com/u/8554242/dmitri/projects/... - At work, I've created a small standalone project with a frontend UI that reused some common structs and html template code between the frontend and backend (ala node.js, except all in Go). - Working on porting my small OpenGL game written in Go to run in the browser. The goal is to have the same Go code use OpenGL when on desktop, but use GopherJS and WebGL when compiling for the browser. Basically, it lets me do all the things that one would normally be forced to use JavaScript for (i.e., frontend code) but without having to use JavaScript (I'm not good at it and I don't like it), while benefitting from Go compiler to catch errors, autocomplete, godocs, goimports, etc. It also allows me to import and use existing Go packages that perform non-trivial tasks.
- syntern 12y agoDo you have any shareable code for the OpenGL cross-compilation?
- shurcooL 12y agoI don't have a complete solution yet, but I can share some links: https://github.com/azul3d/issues/issues/29 https://github.com/azul3d/issues/issues/29 - Very relevant discussion with good resources/links/info. https://github.com/ajhager/engi https://github.com/ajhager/engi - 2D game library for Go with desktop/browser/android targets. https://github.com/shurcooL/play/tree/master/57 https://github.com/shurcooL/play/tree/master/57 - Simple WebGL/GopherJS render triangle demo. https://github.com/shurcooL/play/tree/master/58 https://github.com/shurcooL/play/tree/master/58 - Unfinished attempt to make the above compiled to two desktop/browser targets.
- EugeneOZ 12y agoDoes it add type checks into compiled code to emulate strict typing? Types of variables in the source code we can check by go itself, but there are server responses (JSON) where we don't have checked types. Really interesting.