<p>I wanted to try something new instead of the built in http package. There aren't many frameworks for Go and I know they are mostly discouraged but gin looks good and have 14K stars so I hoped to hear your thoughts and review on it.</p>
<hr/>**评论:**<br/><br/>earthboundkid: <pre><p>I prefer <a href="https://github.com/go-chi/chi">https://github.com/go-chi/chi</a> but really it doesn't matter too much. </p>
<p>Ignore Github stars. The question is "is this software sufficiently maintained for me to rely on it?" That can be true even with 0 stars and false even with 1 million stars (see OpenSSL for a non-Go example of widely used unreliable software).</p></pre>pinpinbo: <pre><p>Another upvote for chi. I don't prefer routing framework that doesn't use <code>HTTPHandler()</code> interface or if they invent their own <code>Context</code>.</p></pre>FPSports: <pre><p>I'm slightly confused about people comparing Chi with Gin.<br/>
Gin is a framework, which uses <a href="https://github.com/julienschmidt/httprouter">httprouter</a> as a router.</p>
<p>Chi is "just" a router with some middleware.</p>
<p>You can't compare those 2 as they don't serve the same purpose and you surely can't recommend one over another.</p>
<p>For OP: what's wrong with the http package? Why do you want to try something new? When I first started doing stuff in Go I was looking for a framework as well, coming from PHP/Symfony2 I was used to that approach. I've been through nearly every framework Go has to offer... at some point I was always hitting a wall deciding that I'm not gonna use that particular framework. The standard-library+a proper router (like Chi) serve me well these days and so far I've not caught myself looking for a framework again. On the opposite, I'm in the middle of writing my own little framework that helps me develop faster. Also helps me learn Go a bit more.</p></pre>MikeTheShowMadden: <pre><p>You can compare them for OP, as it seems OP doesn't really know the difference between a library, framework, or what have you.</p>
<p>Either way, he can offer Chi as an alternative as it <em>seems</em> like it would suffice the OPs needs since he didn't specify needing anything gin offers over Chi. It sounds like he just wants to make a rest service quick, and Chi looks like it can do that.</p></pre>aboukirev: <pre><p>Both are frameworks that come with router, middleware chaining, route and parameters parsing, form binding, rendering HTML/XML/JSON, logging, graceful shutdown, and variety of useful middleware. They just have it organized a bit different: some is sub-packages, some contrib packages, under the same project or in a different project under the same Github account. </p></pre>necrosexual: <pre><p>For me I'd rather use gin that http because I'll be just writing code that someone else has already written, and written better than I could write it.</p></pre>Tikiatua: <pre><p>Gin is a great framework and we used it a lot in the beginning. However we have since switched to <a href="https://github.com/labstack/echo">https://github.com/labstack/echo</a> and are very satisfied with the functionality it provides without trying to do too much.</p></pre>aboukirev: <pre><p>I'll second that. <code>echo</code> is straightforward and has enough features while not being overloaded. I have half a dozen projects using it. It is non-idiomatic. But that also makes it more elegant, concise. <code>gin</code> is non-idiomatic too. </p>
<p>If you want a small fast idiomatic framework, look at <a href="https://github.com/go-chi/chi">https://github.com/go-chi/chi</a></p></pre>VirmundiUndead: <pre><p>Kind of on topic: why not look at gRPC? Are you really doing restful design, ie HATEOAS? If not, why not a binary, documented protocol that's supported by the majority of programming languages including Go and JavaScript?</p></pre>yotamN: <pre><p>I'm actually not creating restful server but a server that returns html pages.</p></pre>VirmundiUndead: <pre><p>Like just serving? If so, why not learn nginx? You'll get to learn about services, and configurations, but get a really quick, custom built problem solver. The reason I pry is to see if you're using the best thing for a problem. Don't get me wrong, Go for the sake of Go is nice too. I just want to do my part to avoid a not-made-here mentality.</p></pre>yotamN: <pre><p>No, they are dynamic (I think this is the correct term). I use the template package to generate the html files with data from the database.</p></pre>VirmundiUndead: <pre><p>That is the correct term. Thanks for asking the questions.</p></pre>014a: <pre><p>If you're serving static HTML, you should really just use <code>http.FileServer</code>. Or nginx. Or, host the files on S3 and enable Static Website Hosting (this option is huge, more people need to use this). </p></pre>zpatrick319: <pre><p>People typically discourage new Go developers from using web "frameworks" because it's valuable to understand Go's http standard library before jumping into someone else's abstraction. Often times, for small projects at least, the standard library has everything you'll need.</p>
<p>That being said, you're going to find common tools/patterns/features useful as you write more web applications. Once you're operating in that context, you can either:</p>
<p>A) Be a "no framework purist", which would require you to copy+paste tools/patterns/features from project to project.</p>
<p>B) Use someone else's package that has the tools/patterns/features you find useful, e.g. gin. </p>
<p>C) Create your own package that has the tools/patterns/features you find useful. </p>
<p>awesome-go is a great resource for checking out go projects, and has a section of web frameworks and middleware: <a href="https://github.com/avelino/awesome-go#web-frameworks" rel="nofollow">https://github.com/avelino/awesome-go#web-frameworks</a> </p></pre>heartwilltell: <pre><p>Maybe you should look at <a href="https://github.com/gobuffalo/buffalo" rel="nofollow">https://github.com/gobuffalo/buffalo</a></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传