I'm writing a program with a go back end that talks to a web front-end and was curious about my options for communication between the two. The front end was started in JavaScript and websockets, but I really don't like working with JavaScript, so switched to Gopherjs with websocketjs but was having tons of issues with implementation.
What other options do I have with gopherJS to communicate between server and client? I would prefer something as simple as websockets to implement.
评论:
scottjbarr:
niosop:If you're building something to run in the browser, JS is really your best bet. GopherJS, while interesting, is going to have some issues. My brief play around with it produced massive, unreadable JS files. Kind of reminded me of CoffeeScript all over again.
You can basically Google your way through building a JS app. You might have a harder time doing that with GopherJS.
I'm not being mean to GopherJS here. I'm sure it suits some people just fine. I find using the right tool for the job at hand is easier. As much as I really love Go, using it to generate the right bit of JS just seems like hard work.
mofirouz:Could try elm and websockets if you wanna dip into FP.
deranjer:What exactly are you trying to achieve? What's the purpose of the website and the back end for it?
LadyDascalie:It is a torrent downloader with a single page webui frontend. The back end sends an update on progress every few seconds and also handles user input from the frontend.
I would prefer something as simple as websockets to implement.
Then... Implement websockets? It's literally as easy as websockets. And it does fit your use case of updating every so often.
I know it's a crappy answer, but to be honest, Javascript just is the most direct answer here.
