<p>Just started learning golang and wanted to build a real time updating and interactive web ui. What are my options for communication between the web frontend and golang back end? I only have a little bit of PHP knowledge with basic HTML, never really done anything realtime.</p>
<hr/>**评论:**<br/><br/>puffybunion: <pre><p>Well, this isn't really a Go question per se, rather you're asking how make a frontend talk to a backend.</p>
<p>Usually, if you're building your frontend in Javascript then you would use something to make HTTP requests to a backend. There are lots of options out there, ranging from good ol' AJAX requests, as well to nicer libraries like axios, the built-in fetch, etc.</p></pre>deranjer: <pre><p>Would you happen to have a good resource for comparing my options? Is there a framework or something that makes it easy to connect with a golang backend?</p></pre>puffybunion: <pre><p>You could get SO many different answers to that question.</p>
<p>If you are used to using PHP, you could use that to build your frontend (I'm not familiar with PHP so can't help you there).</p>
<p>My weapon of choice for frontend applications is React, the official tutorial is pretty great for getting started and you should be able to make a request to a backend server in no time.</p></pre>PacNinja: <pre><p>For real time communication you would use websockets. And for interactive ui you can use a front-end framework(Vue, React etc.) of your choice or just jquery.</p>
<p>Resources:</p>
<ul>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API" rel="nofollow">Javascript API for websockets</a></li>
<li>Libraries/Frameworks: <a href="https://github.com/gorilla/websocket" rel="nofollow">gorilla websockets</a>, <a href="https://github.com/olahol/melody" rel="nofollow">melody</a></li>
<li>Examples: melody's readme, <a href="https://github.com/godwhoa/wsrooms" rel="nofollow">wsrooms</a>, <a href="https://github.com/gorilla/websocket/tree/master/examples/chat" rel="nofollow">chat</a> (search around github you'll find more examples)</li>
<li><a href="https://www.freecodecamp.org/" rel="nofollow">Freecode camp for learning front-end dev.</a></li>
</ul>
<p>Good luck!</p></pre>deranjer: <pre><p>Thanks, after some research I think I might use Vue.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传