<p>Hello all, I have been slowly taking some time playing with GO to try to pick it up and have down a couple small programs to get me started. If I am looking for code review is that something I could post here and get feedback? Any critique is honestly great, no matter how small or big. I come from a background of mostly strict web development so its been nice to try my hand at some newer type of exercises while picking up GO.</p>
<p>I wrote one program for just working with user input:
<a href="https://github.com/justinrsmith/Decision-Maker" rel="nofollow">https://github.com/justinrsmith/Decision-Maker</a></p>
<p>Then I wrote a small tcp client/server since I've never done anything like that:
<a href="https://github.com/justinrsmith/tcp_go" rel="nofollow">https://github.com/justinrsmith/tcp_go</a></p>
<p>Thank you in advance!</p>
<hr/>**评论:**<br/><br/>peterbourgon: <pre><p>I've just looked at the TCP client/server and gotta say, this is great first code. You're doing pretty much everything right, and good job for reaching to package bufio to handle the reads and writes on the connection. </p>
<p>A few small things</p>
<ul>
<li>Constants don't get the ALLCAPS treatment in Go; they'd just be <code>host</code> and <code>port</code></li>
<li>Better to avoid globals and have those defined in <code>func main</code>, or, better yet, taken as flags. </li>
<li>In the <code>if err != nil { log.Fatal }</code> block, better drop the <code>else</code> clause</li>
<li>Can you find a way to read in handleConnection that doesn't require allocating a fixed buffer?</li>
</ul></pre>driusan: <pre><p>On the note of Fatal, you probably also don't want to call it from the server's main event loop since it has a side-effect of quitting the program.</p></pre>lancevo3: <pre><p>Thank you for the feedback! Your last point is something I actually was wondering about myself? Would it make use <code>Scanner</code> to read the input? I'm still working on understand the difference between <code>Reader</code> and <code>Scanner</code> and when to use what.</p>
<p>Also, for your second point (taken as flags), do you mean passed in via the command line when running the program? </p>
<p>Thanks!</p></pre>