Hi,
The simple answer is that yes, you can use either method. I’ve been trying out the Go WebAssembly support, and although it’s very new, it does work … with some caveats.
If you want to try it, my app is online already on my website: http://jayts.com/vp/
(I’ll have some directions for playing the game later, but for now you can just search for “video poker strategy” or the like if you are not familiar with this popular casino game. One thing I’ll say for now is that you can also play using the keyboard, and if you open Developer Tools, you can play the game in the debug console. keys A-I choose different variants of video poker. A manual page for the console version of the game is here: https://github.com/Yaoir/Go-VideoPoker.)
I’m working to get the source code together enough to publish on GitHub. I hope it will help other Go programmers learn about Go’s WebAssembly support and motivate them to try it.
I’m excited about Go and WebAssembly because now it’s possible to do both client- and server-side development (“full stack”) in Go, without writing a single line of JavaScript! And it’s clear that things will only improve (probably quickly) in the future. That’s really cool. But to be realistic, what we have right now is this:
JavaScript: It’s been around since the 1990s, every browser has a good JavaScript engine that can be counted on, and it’s a lot faster (due to compilation of JavaScript code) than it used to be. Virtually all of the documentation on DOM manipulation, event handlers, and such gives examples in JavaScript because for so long, that was the only way to do it. And over the past 2 decades, all sorts of frameworks and libraries have been written for JavaScript programmers, including Angular, Vue, React, and so on.
Go: WebAssembly support is only a couple of months old, and it’s documented like this:
This package is EXPERIMENTAL. Its current scope is only to allow tests to run, but not yet to provide a comprehensive API for users. It is exempt from the Go compatibility promise.
There are limited or no frameworks or libraries available, so it’s like being limited to just plain JavaScript. I’ve seen a few companies developing web apps in plain JavaScript (with no framework), but it is rare.
Having said that, I am really enjoying writing web apps in Go. It seems possible (although more complicated) to do anything with Go that can be done with JavaScript, and for anyone starting off developing a site right now, it would be a bold move to choose Go for both server-side and client-side programming. The whole project can be done in one language that’s far better than JavaScript in so many ways, and in the future, as WebAssembly develops, it could turn out to really pay off.
So it’s the usual situation that early adopters take risks, but if things work out, get the most rewards.