<p>Today I’m going to build a simple API for todo application with the golang programming language. I’m going to use golang simplest/fastest framework gin-gonic and a beautiful ORM gorm for our database work. To install these packages go to your workspace $GOPATH/src and run these command below: <a href="https://medium.com/@thedevsaddam/build-restful-api-service-in-golang-using-gin-gonic-framework-85b1a6e176f3" rel="nofollow">continue reading the full post</a></p>
<hr/>**评论:**<br/><br/>myringotomy: <pre><p>These "build an API" blog posts are wholly inadequate. Where is the logging? Where is the authentication? Where is the permissions system? </p></pre>dcowboy: <pre><p>The trivial example posts are a bit repetitive, but they often use somewhat different approaches to how they handle routing and handlers, framework vs. no framework, gorilla/mux or not, etc. It's nice to see different approaches to solving the same problem. But, yes, most seem to just stop at getting the basic CRUD setup and then go no further. Ultimately I just went and bought some e-books for more a more in-depth look at API creation.</p></pre>myringotomy: <pre><p>Even the simplest app needs logins, permissions, some way to manage configurations and environments, database migrations, etc.</p>
<p>I don't see how writing the ten thousandth blog post on how to do a simple CRUD example helps anybody. Why isn't there a "base" setup which everybody can build on top of and write blog posts about?</p></pre>dcowboy: <pre><p>Right, and as I said, most blogs seem to stop after CRUD and do not add in any of the middleware or other features necessary for a production application. I think a lot of these posts are written by people who are still relatively new to Go and are writing the posts to help clarify their own understanding more than trying to teach Go API design to others. And there's nothing wrong with that.</p></pre>myringotomy: <pre><p>You say there is nothing wrong with that but maybe there is something wrong with that. First of all it's of dubious value because it's one of ten thousand posts that are almost exactly the same. Secondly when you look at tutorials from other languages they are much more sophisticated because the basics are covered by the language or the framework. So instead of talking about CRUD they are talking about cache management, or clustering or invalidating JWT tokens or encrypting user passwords properly and securing your apps. That might give people the impression that those languages are more suitable for real world apps.</p></pre>ptdave: <pre><p>I find creating a struct of an intended api is better, then creating functions on that struct for the individual api routes. Helps keep things clean and easy on naming.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传