Go-lang web dev frameworks

polaris · · 546 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi, I want to check out golang for making web apps. What are the cool cats using to develop web apps in 2017? </p> <p>Thanks.</p> <hr/>**评论:**<br/><br/>icholy: <pre><p>Just use the standard library. Grab a 3rd party router if you need it.</p></pre>H1Supreme: <pre><p>Maybe something to handle user auth too. But, overall a router and Go&#39;s standard library is all I&#39;ve ever needed.</p></pre>emansom: <pre><p>net/http</p></pre>m3wm3wm3wm: <pre><p>I love it how this sub gets this same question on a weekly basis.</p></pre>edgardcastro: <pre><p>I&#39;m enjoying using <a href="https://echo.labstack.com/" rel="nofollow">echo</a> as a micro web framework <em>a lot</em>.</p> <p>Also, <a href="http://jinzhu.me/gorm/" rel="nofollow">gorm</a> for your orm needs.</p></pre>dlsniper: <pre><p>Or sqlx </p></pre>eaglex: <pre><p><a href="https://gowebexamples.github.io/" rel="nofollow">https://gowebexamples.github.io/</a></p></pre>pkieltyka: <pre><p>My take:</p> <p>router: <a href="https://github.com/pressly/chi" rel="nofollow">https://github.com/pressly/chi</a></p> <p>database querying and struct mapper: <a href="https://github.com/upper/db" rel="nofollow">https://github.com/upper/db</a></p></pre>iends: <pre><p>I&#39;ve never seen upper before, it looks nice. However, none of the examples or documentation talks about joins. Is the only option to use the query builder?</p></pre>Zamicol: <pre><p>See the Awesome list:</p> <p><a href="https://github.com/avelino/awesome-go#web-frameworks" rel="nofollow">https://github.com/avelino/awesome-go#web-frameworks</a></p></pre>fancy_pantser: <pre><p>Basics: <a href="https://golang.org/doc/articles/wiki/" rel="nofollow">https://golang.org/doc/articles/wiki/</a></p> <p>Popular router/dispatcher: <a href="https://github.com/gorilla/mux" rel="nofollow">https://github.com/gorilla/mux</a> </p> <p>Get you some middleware handling -- Negroni is popular: <a href="https://github.com/urfave/negroni" rel="nofollow">https://github.com/urfave/negroni</a></p> <p>Datastores: choose your own adventure! There are many. For RDBMSes at a slightly higher level, try <a href="http://jinzhu.me/gorm/" rel="nofollow">GORM</a> or <a href="http://jmoiron.github.io/sqlx/" rel="nofollow">sqlx</a>.</p></pre>robvdl: <pre><p>I wouldn&#39;t really recommend GORM anymore:</p> <ul> <li>Automigrate is so basic that it won&#39;t even put constraints on foreign keys (unless that has been fixed since, you just end up with simple integer fields without constraints on them)</li> <li>Embedding *gorm.Model is weird, it adds columns like deleted_at and encourages soft deletes, leaving the record behind and marking it as deleted instead.</li> <li>I have read multiple times now on Reddit golang that the code base is pretty bad and in dire need of fixing up, all while better alternatives have popped up.</li> </ul> <p>See: <a href="https://www.reddit.com/r/golang/comments/5pgma4/my_quest_to_improve_gorm_the_object_relational/" rel="nofollow">https://www.reddit.com/r/golang/comments/5pgma4/my_quest_to_improve_gorm_the_object_relational/</a></p> <p>Also sqlx is low-level, not high-level, it encourages you to write SQL by hand which makes it low-level in my books.</p></pre>fancy_pantser: <pre><p>Why not &#34;anymore&#34;? These are not new features.</p> <p>Embedding is how golang handles data structure inheritance; it would be weird to do it another way. In many basic CRUD applications, soft-deletion is what you want for many tables so they built it in. <a href="https://github.com/jinzhu/gorm/issues/1163" rel="nofollow">You don&#39;t have to embed gorm.Model in your structs or use soft delete</a> (aka tombstones). You can add/remove/modify your model structs at will to use all/some/none of the &#34;batteries included&#34; GORM features.</p> <p>Personally I like working from the DB -&gt; code and not the other way around when it comes to Go, so <a href="https://github.com/vattle/sqlboiler" rel="nofollow">SQLBoiler</a> is my jam. It&#39;s also much faster in benchmarks. I didn&#39;t recommend it above, however, because OP is new to writing webapps in Go and asked what&#39;s popular (and, I assume, they&#39;ll find lots of support material for).</p> <p>Finally, I&#39;m glad that we agree that sqlx is slightly higher than low-level. I recommend it here because it&#39;s widely used and lets anyone already comfortable with SQL just get the job done at the query level without the nitty-gritty of manual marshaling.</p></pre>robvdl: <pre><p>The only reason I mentioned &#34;anymore&#34; is because I used to use it a LONG time ago, before I even came across sqlx and sqlboiler, when there weren&#39;t all that many choices, e.g. it was GORM or GORP or stdlib. I thought it was an OK library at first, but it wasn&#39;t until later I realised that the auto creation of tables from models didn&#39;t even create foreign keys properly, as in they were lacking the constraints on them which made the auto create feature kind of useless. The soft deletes were also kind of a &#34;surprise&#34; to me at first, but I do realise you don&#39;t have to have the deleted_at field either... it was just an odd surprise to me at the time.</p> <p>With soft deletions you constantly have to be aware of &#34;deleted&#34; records in your querying, what if you join to something that is &#34;soft deleted&#34; for example, you can get your data in an inconsistent state that way too.</p></pre>fancy_pantser: <pre><p>There still aren&#39;t many &#34;complete&#34; ORMs to choose from and they all have some big tradeoffs. I&#39;m still not completely satisfied with anything I&#39;ve tried, but I do check out new ones when they get past the &#34;pet project&#34; stage.</p> <p>What would you look for in an ideal Go ORM? Is it just &#34;a Rails/Django/Hibernate/... clone&#34; or something that takes specific advantage of the language and common patterns?</p></pre>robvdl: <pre><p>I&#39;m not really sure now what I would want out of a Go ORM, I have spent quite a few years with Django, and in the last year I have done a lot of very complex SQLAlchemy querying using the ORM and SQLAlchemy query like language. I am kind of over ORM&#39;s I think after that project, SQLAlchemy is a complex beast to master but it taught me a lot more about just writing SQL by hand instead. So I was more thinking of avoiding ORMs all together in Go and just doing raw SQL instead.</p></pre>apxp: <pre><p>GoBuffalo</p></pre>hoffentlich: <pre><p>What an ugly pasta mix. </p></pre>sybrandy: <pre><p>I personally like httprouter. While it is supposed to be fast, I just really like it because I find it easier to create my rest endpoints when I declare them per method and per path vs. how the default net/http mux works. However, this is personal preference more than anything else.</p></pre>DustinHeroin: <pre><p>Anyone a fan of <a href="https://github.com/valyala/fasthttp" rel="nofollow">fasthttp</a>? Echo v2 used to support it. Not sure why other web frameworks haven&#39;t thought of taking advantage of it yet.</p></pre>

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

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