<p>During my journey learning GO I found the following questions several times: "How do I struct GO applications?", "There is any good project as example?”. </p>
<p>Well, I also made this question! Every example that I found they just simply put everything in the same package... So I decided to create IMGART project as an example of a real application.</p>
<p>IMGART consists is a HTTP Service for image processing based on filters and profiles: <a href="https://github.com/talento90/imgart">https://github.com/talento90/imgart</a></p>
<p>List of features that you can find in this project:</p>
<ul>
<li>HTTP API Middlewares (logging, serialization, error handling)</li>
<li>Documentation using Swagger Specification</li>
<li>Dockerfiles (Development and production)</li>
<li>Multiple databases (Redis for image caching and MongoDB for profiles)</li>
<li>Graceful Shutdown</li>
<li>Healthcheck</li>
<li>Debugging with Delve, VSCode and Docker</li>
<li>Error Handling</li>
<li>Make file</li>
</ul>
<p>I am thinking about creating a blog post serie explaining my decisions... What do you think?</p>
<p>I would appreciate your feedback (negative/positive)</p>
<p>Happy coding :)</p>
<hr/>**评论:**<br/><br/>shovelpost: <pre><p>I think that we are talking about a very good package structure. My opinion is that if you remove the unnecessary <code>pkg</code> it will become even better.</p></pre>Talento90: <pre><p>I have thought about that a million times and I am still thinking about removing <code>pkg</code> folder, but at the same time I think it makes sense to separate the deliveries <code>cmd</code> folder from the application code! So I live in a mix feelings about this :)</p></pre>shovelpost: <pre><p>Using a <code>cmd</code> folder is a very common pattern in Go projects. By having a <code>cmd</code> folder you are already separating your commands from the application code. Therefore there's no need to do an extra separation.</p>
<p>Having good package names (like yours) allows to very easily see the different concepts of the project as soon as you visit the code repository. But as it is now, they are all hidden behind the <code>pkg</code> folder.</p></pre>kostix: <pre><p>Pleas please please don't forget spill the "web" word all over your text when you're talking about web applications. Go is not about web only.</p></pre>megamark16: <pre><p>Last night I thought about brushing up on Go and literally googled four "golang project structure best practices". So, yes, yes please!</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传