Code review request (Config Server)

xuanbao · · 451 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hey everyone, I&#39;ve started to build little practical applications that I and other people can use while also learning how to effectively program in Go. Before I get into the details of my project, I&#39;d first like to preface that I&#39;m a self taught programmer, I&#39;m still learning so please take that into account when responding. Anyways here we go.</p> <p>This application serves a single file from memory to a client which gives a browser logic to route traffic to proxies such as Squid. While looking at this code I&#39;d like to add that there are things that still need to be worked on:</p> <ul> <li>More / descriptive comments.</li> <li>Unit tests.</li> </ul> <p>My main goals of this application is to solidify a template of sorts for future projects like this to build upon (While also just coding a basic app with this current app). I don&#39;t use any frameworks since it seems that everyone has decided to just use the stdlib also it&#39;s one less dependency you have to worry about. Anyways, here is my code: <a href="https://github.com/junland/pac-mule">HERE</a></p> <p>Let me know what you think and thank you so much your time!</p> <hr/>**评论:**<br/><br/>i_regret_most_of_it: <pre><p>Use <code>go fmt</code>. Use an editor that automatically runs <code>go fmt</code> on save.</p> <p>Use <code>log.WithField</code>/<code>log.WithFields</code>/<code>log.WithError</code> if you&#39;re going to use a structured logging library like logrus.</p> <p><code>cmd/*</code> should be package main/the entrypoint(s) to your application, your root directory and its other subdirectories should contain the rest of your code (subject to taste).</p> <p><a href="https://github.com/junland/pac-mule/blob/dc72a60dc54c20b43c537a5bbe8b297794e5ce87/server/server.go#L34">You probably shouldn&#39;t be terminating the process from a non-main package</a>, instead propagate the error to the main program.</p></pre>supermudkip: <pre><p>Awesome thanks! </p> <p>About the go fmt thing, it looked just fine on Atom, now looking at the Github page it looks nasty. Sorry about that, I&#39;ll have to tune some stuff in my editor.</p> <p>Also is there any reason why you wouldn&#39;t terminate processes outside of non-main packages?</p></pre>

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

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