Review Request: Trying my hands on channels

agolangf · · 509 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello Great Gophers!</p> <p>I devised a solution for [Advent Of Code](adventofcode.com)&#39;s 11th Day. It&#39;s a simple password generation while incrementing a text one by one like it would be a number. </p> <p>I tried to do it with channels. The one without channels and []byte works perfectly. This one, not so much. :) </p> <p>What my vision was is the following =&gt; </p> <p>Have one buffered channel in which the password generator routine puts passwords into. The buffer shall be, like 100 passwords. Then have the checker routine which gets passwords FROM the generators buffered channel and checks them. It returns once it find a correct password. </p> <p>I <em>THINK</em> I implemented this correctly, but if I understand it right, the checking is not in the same order as the passwords are put into the channel maybe? </p> <p>Could somebody please take a look and say if my Channel implementation is correct? I&#39;m guessing it isn&#39;t. :) Or that the two routines shouldn&#39;t be kicked of that way... Or anything is welcome, really.</p> <p>Thank you ever so much!</p> <p>Here is the Code =&gt; <a href="https://github.com/Skarlso/goprojects/blob/master/advent/solutions/password.go" rel="nofollow">Gihub Advent Of Code Day 11</a></p> <p>Unfortunately the play.golang.org URL wasn&#39;t working because the process took too long. :( Sorry about that. But here it is never the less =&gt; <a href="https://play.golang.org/p/RcWeTmAB-7" rel="nofollow">Playground For Day 11</a>.</p> <p><strong>EDIT</strong>:</p> <p>I think I&#39;m missing a <code>break</code> after this, no? </p> <pre><code> if checked { output &lt;- s //insert break here... } </code></pre> <p>Thanks very much everyone!</p> <hr/>**评论:**<br/><br/>skarlso: <pre><p>Why the downvote? An explanation would be nice.</p></pre>

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

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