I'm writing a book and would love your feedback.

agolangf · · 511 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello there,</p> <p>I&#39;ve built two startups using Go as backend in the last three years, and I decided to write a book going over what I think is a good path to having an API-first Go web application for software as a service product.</p> <p>This is the book l<a href="https://buildsaasappingo.com/">anding page</a>, but I&#39;m interested in getting feedback regarding the table of content:</p> <ol> <li>Let&#39;s Go: Create a simple web application to get started with Go.<br/></li> <li>Tests are important: Balance speed of development and importance of tests.</li> <li>A 50 lines web framework: We craft ourselves a tiny foundation with no dependencies. </li> <li>The data package: MongoDB because we&#39;re creating a SaaS and it&#39;s evolving each day.</li> <li>API-first my friend: Your users want an API, give them on day 1.</li> <li>Authorization middleware: How users are created and how they can authenticate &amp; authorize requests.</li> <li>Single page application: Build a lightweight SPA with TypeScript, Preact, Bulma, and webpack.</li> <li>Billing and subscriptions: We use Stripe to build a full real-world billing system.</li> <li>Emails &amp; background tasks: Go routines in all their glory, no need for external processes.</li> <li>Capture and replay: Log failed requests and run them against your dev environment.</li> <li>Zapier integration: No matter what you&#39;ll build, Zapier will be there.</li> <li>Automated deployment: We build our own CI in Bash and Go (for real).</li> </ol> <p>Would you say that I&#39;m missing something here? Any suggestions would be highly appreciated.</p> <p>I&#39;m not sure about chapter 7 where mixing UI within a Go book could be too much. Also, one chapter to go over a basic UI could be too short. But the reader would have a backend API at the end of the book otherwise...</p> <p>My humble goal with this book is to demonstrate that Go is a solid choice for building a SaaS products and maybe try to get some RoR and Python devs to discover a new stack. If nothing more than pique their curiosity, that would still be a win I think.</p> <p>Thank you.</p> <hr/>**评论:**<br/><br/>733138: <pre><p>Looks very nice. Except for MongoDB. If I were you, I would write 2 books: this one without chapter 7 &amp; replacing mongo with anything else (sqlite maybe?), and another one just front-end oriented (this one including ch. 7). Just my 2 cents.</p> <p>Either way, keep it up! </p></pre>dstpierre: <pre><p>It is funny because I&#39;m aligned with what you&#39;ve said and had considered it at first, but removing the entire chapter felt incomplete.</p> <p>What&#39;s up with MongoDB and the Go community :)? But I hear you, so far it is a recurring feeling. I&#39;m using MongoDB at Roadmap and must say that so far it is not bad for this use case.</p> <p>Thank you for the feedback.</p></pre>neoasterisk: <pre><blockquote> <p>What&#39;s up with MongoDB and the Go community :)?</p> </blockquote> <p>I don&#39;t think it has to do with the Go community in particular. In fact I know many gophers who love Mongo especially since we&#39;ve had a very good driver for a long time now. I think it&#39;s actually more of a <a href="http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/">general issue</a>.</p></pre>joper90: <pre><p>But when you google for &#39;not using mongo&#39; all the articles pretty much point back to that one..?</p></pre>neoasterisk: <pre><blockquote> <p>But when you google for &#39;not using mongo&#39; all the articles pretty much point back to that one..?</p> </blockquote> <p>Maybe they do, maybe not. What&#39;s your point? </p> <p>Really just think for yourself. Is MongoDB a good fit for your project? if it is then use it. But here we have an author that is writing a book and is asking for feedback. MongoDB can only be used for very, very, very specific data models and situations. As far as I am concerned it&#39;s a very bad fit for a learning book.</p></pre>coder543: <pre><p>There are countless articles that explain why you should never, under any circumstances, use MongoDB. The golang community is understating this, if anything, compared to most communities. Use anything and everything else before turning to Mongo. Unless you enjoy losing data, or being unable to do basic things without destroying performance.</p> <p>Just because you haven&#39;t had it blow up in your face <em>yet</em> doesn&#39;t mean it&#39;s a good idea. Some people get lucky while walking through a minefield, but that luck runs out sooner or later.</p></pre>joper90: <pre><p>But most of the countless articles seem to point back to that one article. </p></pre>coder543: <pre><p>&#34;that one article&#34;</p> <p>When writing an article like these, it&#39;s usually standard practice to link to other corroborating sources. They&#39;re not all summarizing a single article. There are a number of unique experience reports and interactions with the MongoDB team which have been written up, and naturally those will link to articles in the same vein.</p></pre>arp242: <pre><p>MongoDB :-(</p></pre>dstpierre: <pre><p>haha yeah, this is generally the response, hmm. I don&#39;t want to get too verbose in the &#34;data access&#34; package. But I might use a RDBMS.</p> <p>Thanks for your feedback :)</p></pre>drink_with_me_to_day: <pre><p>Does it even make sense to use mongodb with Go, wouldn&#39;t it become some interface{} hell?</p></pre>natefinch: <pre><p>I worked with mongodb for 3.5 years on Juju. It&#39;s not interface{}. It&#39;s basically like JSON serialization.... structs in and structs out. </p> <p>It lowers the barrier of entry, but in my experience, most people that use it really should just use a relational database like postgres, because the lack of relational functionality really hurts the long term stability and velocity of a project. Most projects store highly structured data (see the part about &#34;structs&#34; above)... that&#39;s what relational databases are for.</p></pre>arp242: <pre><p>It certainly wouldn&#39;t make too much sense conceptually, IMHO. Go is all about safety and being &#34;boring&#34;. MongoDB is the exact opposite.</p></pre>coder543: <pre><p>MongoDB, for when you want an <em>exciting</em> database. Maybe you&#39;ve been sleeping too well at night... well, sleep no more! Introducing Mongo!</p></pre>dstpierre: <pre><p>You still have struct to define your data, this is an example of production code I have `similar.</p> <pre><code>var account Accounts where := bson.M{fieldEmail: email} if err := db.C(collectionAccounts).Find(where).One(&amp;account); err != nil { } </code></pre> <p>I&#39;m thinking of having the data package targeting sqlite and Mongo maybe that could be an idea to have a straight comparison for the reader of the book. Not sure yet.</p></pre>scottjbarr: <pre><p>Maybe use a &#34;Repository&#34; interface and put the data details behind that? You can discuss the pro&#39;s and con&#39;s of each datastore specifically, without it influencing the whole book as the &#34;business logic&#34; works with the interface.</p></pre>puffybunion: <pre><p>This looks great. If it doesn&#39;t take anything from the rest of the book, I don&#39;t think it&#39;s a bad idea to have the UI chapter as well.</p> <p>Would love to get my hands on this when it gets published!</p></pre>dstpierre: <pre><p>Thank you. That&#39;s the issue with the UI chapter, I feel it is going to be huge, so I either will do a quick one or not at all.</p> <p>You can keep in the loop via my <a href="https://twitter.com/dominicstpierre" rel="nofollow">Twitter account</a></p></pre>musale13: <pre><p>Code optimization techniques? Go tracer... etc I am usually interested in such kind of tools. </p></pre>dstpierre: <pre><p>Yes thanks for the suggestion, that could be a good one to replace the UI chapter.</p></pre>NSABeaver: <pre><p>When is the target release date of the book ?</p></pre>dstpierre: <pre><p>I&#39;m sorry, I don&#39;t have an ETA at the moment. Ideally sooner than later. I will have a more valid ETA in the following week.</p></pre>absdevops: <pre><p>Might be a little unrelated to projects, but something like advanced manipulation of structs would be cool</p></pre>Neorift: <pre><p>What kinds of struct operations fall into that category?</p></pre>absdevops: <pre><p>So a while back on here I was helped with <a href="https://gist.github.com/arehmandev/87a63bf5964ce4a8833294fb831c6373" rel="nofollow">this json transformation</a> - it would be nice to see more solutions to real world tiny issues like this</p></pre>peartreeer: <pre><p>Love the sections (except I&#39;d also throw my hat in to say use a relational database). Only thing I&#39;d like to know more about, which would be filtered throughout the book is best debugging tips and tricks you may have. Go&#39;s pretty awesome about tracing but if you&#39;ve come across any particular helpful tricks that&#39;s always nice for the reader.</p> <p>Looking forward to it&#39;s release!</p></pre>dstpierre: <pre><p>Thank you that&#39;s a good suggestion, it could be a good chapter replacing the UI one if I remove that one.</p></pre>dstroot: <pre><p>Some thoughts: 1) I echo the Mongo DB comments - use Postgres 2) SPA&#39;s are a little unique and I don&#39;t see how Go fits except to serve the assets. I&#39;d use Vue or React and also GraphQL if I was starting from scratch today for an SPA. 3) If I was starting today I would have full tracing throughout my apps. Check out the HotRod example in Jaeger! 4) Auth is a minefield, if you can do it justice it would be very beneficial. Users auth with ID/Pswd, or OAuth (use FB and Google) and app uses JWT(?). I like JWT but refreshing them is awkward and canceling them is hard.</p> <p>Orthogonal: I am a &#34;mini-angel&#34; investor. Did your startups succeed? If so, why? If not, why not? </p> <p>Cheers, Dan</p></pre>dstpierre: <pre><p>Thanks for the suggestions, point 3 and 4 are very important. I was planning on having Slack as an OAuth source and JWT for authenticating requests.</p> <p>re: startups succeed. I left LeadFuze after almost 2 years when the product was fully built I&#39;d say, we were doing good. I started Roadmap after leaving LeadFuze. We&#39;ve had a pretty strong starts, some roller-coaster startup-like adventure. Now it is just me at the moment, we were 4 after I launched the MVP.</p></pre>matiasbaruch: <pre><p>It might be interesting to include a section about Redis (or similar software).</p></pre>dstpierre: <pre><p>Yes absolutely, I think if I decide to remove the UI chapter that will leave some room for caching and other techniques, good point thanks :)</p></pre>NilByDefault: <pre><p>Great stuff, I&#39;ll be your reader! One question, do you use Docker anywhere in your process? For example, building SPA must require lots of dependencies, which I would bundle in a docker image. The same applies to Mongo, spinning up MongoDB within a container seems a way easier to me. Unless, your custom built CI does the same))</p></pre>dstpierre: <pre><p>Thank you, that is so re-comforting to hear :). I wasn&#39;t planning on using Docker, but maybe that could be easier to get started. The CI is more a CD in fact, looks like I did a typo there, It is a small Go app that automates the deployment of the app from a GitHub branch with multiple app environment bound to specific GitHub branch like master=production, staging, dev. </p></pre>

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

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