<p>What are your most useful methods, libraries, and tips you use to quickly iterate over you Go project to quickly implement changes and or release a new version to your server.</p>
<hr/>**评论:**<br/><br/>beeker1121: <pre><p>I think first and foremost is having a solid foundation for your application.</p>
<p>Building the structure, that foundation, is what will take the longest. For instance, you start building the API and then realize you should probably code up proper error handling to match JSONAPI specs.</p>
<p>Once this structure is in place though, adding to it becomes a much faster process because it's already there, you just have to basically copy the same logic and methods over to the new routes, services, etc that you create.</p>
<p>Tbh I spent a lot of time building my current SaaS project, but a large part of that was learning Go. Shameless plug here btw because I'm a single founder and need the traffic :) <a href="https://maildb.io/">https://maildb.io/</a> . Everything on there is coded in Go, including the crawler application.</p>
<p>I'm thinking of doing a blog post about how my app is structured, similar to what another gopher posted not too long ago. If anyone is interested let me know, I wanna cover as many aspects of building a production level SaaS application in Go as I can.</p></pre>tylermumford: <pre><p>I would be interested in a post (or series) about that. Architecture is what I love most about programming right now, and I'd be thrilled to get a look under the hood of a production Go system.</p></pre>kiwihammond: <pre><p>With the permission of my employer at the time, I put together <a href="https://github.com/kiwih/heyfyi" rel="nofollow">this example</a>, which is architectured very closely to what our production system was at the time. You might be interested in the architecture diagram embedded in the readme! </p></pre>tvmaly: <pre><p>I also created my current side project in Go, it was how I taught myself Go. For me using a Makefile to handle all of the other parts such as compiling SASS, minifying javascript was important. </p>
<p>I like your project, I did something similar to this back in the day on a limited scale for university emails using Perl.</p></pre>beeker1121: <pre><p>Same here I have bash scripts for each application, handling deployment. Probably a better way but it gets the job done well.</p></pre>seriouslulz: <pre><p>Go for it fam</p></pre>tiberiousr: <pre><p>I C what you did there.</p></pre>s-expression: <pre><p>When designing the software, model your data structures first. Your data structures are the most important part of the system, especially when it comes to refactoring and iterating. How data is stored, retrieved, processed, and presented (via an API if you have one) is all secondary to how your application represents the data internally. A poor data structure is going to have a poor persistence model, poor algorithms, and a poor API.</p>
<p>If I'm making something with an HTTP API, I prefer either using just <code>net/http</code> or if I need a third-party router, one that is easily compatible with <code>net/http</code>. This excludes most routers/frameworks with nonstandard handler signatures, but ensures that <em>if I do</em> need to change something, I have less work to do.</p>
<p>Encapsulate. If you're not hiding information, refactoring and iterating is more difficult. If you find yourself frequently "reaching through" several nested layers of custom data structures, you should revisit your abstractions. I say "custom" here because standard library data structures are practically guaranteed not to change in incompatible ways. But it's still a good idea to encapsulate there too; it not only makes your module's API more clear, but allows for changes in the implementation without affecting anything outside of your module.</p>
<p>An extension of encapsulation is a gratuitous use of interfaces. Methods that accept interfaces are more flexible for clients and make refactoring, iterating, <strong>and testing</strong> a breeze. If a module's API utilizes structs with methods, try to make them interfaces instead.</p>
<p>Releasing the software: continuous integration. Get some sort of pipeline running so that you can quickly build your entire software package. Depending on your application and its dependencies, Docker can help here.</p></pre>fmpwizard: <pre><p>For deployment, I love using ansible, reading the yml files is really close to what a hand made command would look, so it's easy to learn. I published this sole API with ansible playbooks that take a fresh Fedora 24 server with almost nothing in it and adds all I need and then copies my go program over, and restarts the service, it even has code for SELinux <a href="https://github.com/fmpwizard/mrwilson/tree/master/ansible" rel="nofollow">https://github.com/fmpwizard/mrwilson/tree/master/ansible</a> , </p>
<p>+1 the other comment about only using a router that is net/http compatible </p>
<p>I also use rego to build my go program as make changes <a href="https://github.com/sqs/rego" rel="nofollow">https://github.com/sqs/rego</a></p></pre>tvmaly: <pre><p>thanks for the ansible share. I have documented how I build all of my non go code like nginx and postgresql. I need to automate some of this including upgrading newer versions</p></pre>shadowmint: <pre><p><a href="https://github.com/Masterminds/glide" rel="nofollow">https://github.com/Masterminds/glide</a> to solve package management issue.</p>
<p><a href="https://github.com/grpc-ecosystem/grpc-gateway" rel="nofollow">https://github.com/grpc-ecosystem/grpc-gateway</a> to write service api end points</p></pre>dazzford: <pre><p>This honestly has nothing to do with go.<br/>
Proper system design and tooling is important no matter what language you use. </p>
<p>So that said, I think what most folks have said still apply.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传