Learning Go - can someone give me an app to make to leverage Go's concurrency?

blov · · 477 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I want to do some practise with Go&#39;s concurrency as I&#39;m finding it quite different to languages I&#39;m used to.</p> <p>Can someone give me a simple application to make that&#39;ll require me to use channels/goroutines.</p> <p>I want something I can load test against and see some impressive concurrent numbers/users.</p> <hr/>**评论:**<br/><br/>adiabatic: <pre><p>Make a clone of wget or curl. Specifically, curl&#39;s &#34;download a bunch of files specified with a glob&#34; functionality. </p></pre>tednaleid: <pre><p>That&#39;s pretty much what I did (am doing) to learn go. I&#39;m creating a utility (<a href="https://github.com/tednaleid/ganda" rel="nofollow">https://github.com/tednaleid/ganda</a>) that I can stream urls to over stdout and it will request them concurrently and either write the output to stdout or write them to individual files. It&#39;s been a great, relatively small, problem for learning golang.</p></pre>bustyLaserCannon: <pre><p>Sounds good! I like it!</p></pre>jechols: <pre><p>Chat server. Go has a great terminal and ssh library in the x/crypto package, so you aren&#39;t reinventing too many wheels, and you can go command-line (ssh) only, so you don&#39;t need to learn Go web templates while also learning concurrency.</p> <p>A simple chat server can have a global channel so you&#39;re doing very simple message processing. You can get it more and more complex as desired to make for lots of channels (per-room, perhaps) and goroutines that manage user events.</p></pre>redditbanditking: <pre><p>+1 for a chat server</p></pre>titpetric: <pre><p>A simple http server will use a goroutine for each HTTP request by default. You can take a look at <a href="https://github.com/titpetric/sonyflake" rel="nofollow">titpetric/sonyflake</a> for an ID generation service, which doesn&#39;t need additional service dependencies like databases or whatever. Or you can do anything else within your http handler that doesn&#39;t need a global state, as the ID service is synchronized between coroutines (mutex, i think).</p></pre>ruertar: <pre><p>Write a simple travel website. Start by figuring out how to query a couple of airline&#39;s websites -- you don&#39;t even have to worry about parsing them to start.</p> <p>So write a front end that takes queries like, &#34;I want flights from MCO to PRG from May 1 - May 12&#34;. Then launch go routines that each queries the backend sites. Consider using contexts to cancel the queries if they don&#39;t complete within an acceptable timeframe. This should let you use go-routines and channels.</p> <p>Then maybe you can go as far as to pre-load data for nearby times -- like if I say I want to travel from MCO to PRG from May 1 - May 12, perhaps in the background you can start loading adjacent days.</p> <p>Ultumately what I&#39;d like is a site that shows a grid like Google&#39;s &#39;Flexible Dates&#39; interface. I imagine each box in the grid could be a go-routine. <em>shrug</em></p></pre>OhGodNotHimAgain: <pre><p>Perhaps something such as a Website which has a queueing system? You could use channels so that you&#39;re only adding one person to the queue at a time.</p> <p>There&#39;s probably something more interesting than this though.</p></pre>earthboundkid: <pre><p>SHA-256 a bunch of files for use with the new integrity attribute of HTML. </p></pre>bustyLaserCannon: <pre><p>That sounds interesting, can you tell me more? I haven&#39;t heard about the integrity attribute</p></pre>earthboundkid: <pre><p>It&#39;s new. So far only Chrome and Firefox support it. See <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity</a></p></pre>bustyLaserCannon: <pre><p>What exactly would a go app do to help this though?</p></pre>earthboundkid: <pre><p>Simple thing: create the sha. </p> <p>Complex thing: update the HTML. </p></pre>bustyLaserCannon: <pre><p>Do you mean like a build step thatd run some asset files through the code to generate the hash then output?</p> <p>Or do you mean a webserver that&#39;d serve up html with the hash injected in the body in the tags?</p></pre>DhiaTN: <pre><p>Check here this material &#34;Visualizing Concurrency in Go&#34;: <a href="https://twitter.com/DhiaTN/status/853404253934809089" rel="nofollow">https://twitter.com/DhiaTN/status/853404253934809089</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

477 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传