<p>I want to do some practise with Go's concurrency as I'm finding it quite different to languages I'm used to.</p>
<p>Can someone give me a simple application to make that'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's "download a bunch of files specified with a glob" functionality. </p></pre>tednaleid: <pre><p>That's pretty much what I did (am doing) to learn go. I'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'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't reinventing too many wheels, and you can go command-line (ssh) only, so you don't need to learn Go web templates while also learning concurrency.</p>
<p>A simple chat server can have a global channel so you'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't need additional service dependencies like databases or whatever. Or you can do anything else within your http handler that doesn'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's websites -- you don't even have to worry about parsing them to start.</p>
<p>So write a front end that takes queries like, "I want flights from MCO to PRG from May 1 - May 12". Then launch go routines that each queries the backend sites. Consider using contexts to cancel the queries if they don'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'd like is a site that shows a grid like Google's 'Flexible Dates' 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're only adding one person to the queue at a time.</p>
<p>There'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't heard about the integrity attribute</p></pre>earthboundkid: <pre><p>It'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'd serve up html with the hash injected in the body in the tags?</p></pre>DhiaTN: <pre><p>Check here this material "Visualizing Concurrency in Go": <a href="https://twitter.com/DhiaTN/status/853404253934809089" rel="nofollow">https://twitter.com/DhiaTN/status/853404253934809089</a></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传