<p>It's only been a few months since I started working on Go. I have a microservice architecture for a web app I'm developing, in the process, I ended up creating a very small framework (<em>with external dependencies</em>).</p>
<p>I ran some basic benchmarking on it and didn't seem bad, I'd like your opinion/feedback/advice to improve it.</p>
<p>Here's the Github repo, <a href="https://github.com/bnkamalesh/webgo" rel="nofollow">WebGo</a>.</p>
<hr/>**评论:**<br/><br/>Grundlebuttskin: <pre><p>It looks like you're missing a defer on the unlock within Context.copy. I like that you have CORS on here and an extensible middleware system. That means I could add logging, authentication, and all the other things I'd need in a real app. I don't use mongo, and I'm not sure I could hook this up to a different data store without modifying the framework itself. I also prefer goji's use of net/x/context because it's immutable and is what some other libraries, such as pat and appengine, use for request-scoped values. It looked like you're doing a bunch of unnecessary manual json decoding for the config; I'm not sure why you didn't just use encoding/json.Unmarshal.</p></pre>kamaleshbn: <pre><blockquote>
<p>It looks like you're missing a defer on the unlock within Context.copy</p>
</blockquote>
<p>I should have spent more time looking into the 3rd party libraries I'm using, because the context part is coming from <a href="https://github.com/alexedwards/stack" rel="nofollow">Stack</a>. Thanks for that.</p>
<blockquote>
<p>I don't use mongo, and I'm not sure I could hook this up to a different data store without modifying the framework itself.</p>
</blockquote>
<p>Unfortunately, I haven't documented any of the APIs or how exactly to use the system itself. My bad, but you <em>can</em> use any DB you like, just that you'll have to add all the required functionalities on your own, and you can set it inside the <em>Globals</em> struct, <em>App</em>, which is a <code>map of string of interface</code>. </p>
<blockquote>
<p>It looked like you're doing a bunch of unnecessary manual json decoding for the config; I'm not sure why you didn't just use encoding/json.Unmarshal.</p>
</blockquote>
<p>True, I should have. Again, I'm using a 3rd party library to read JSON (<a href="https://github.com/bitly/go-simplejson" rel="nofollow">Simple Json</a>), why I did this is so that you can include any config in your JSON file, not just the framework's. And you wouldn't have to define a struct to read it. And I thought I could let the <em>unnecessary</em> json reading stuff slip, since it's only a one time thing, when starting up the server.</p>
<p><strong>Thanks a lot for the feedback!</strong></p>
<p>P.S: I will be updating the <a href="https://github.com/bnkamalesh/webgo-sample" rel="nofollow">webgo-sample</a>, showing how to use all the APIs of the framework.</p></pre>lansellot: <pre><p>Go. Not GoLang, not golang, not Golang. Just Go.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传