Most of my experience as a developer is making CRUD web API servers in C#. I organize them using the Model-View-Controller structure, often with a Repository layer for MySQL queries.
In learning Go, I have learned that the MVC pattern is not recommended in Go (link). Instead, I’m supposed to use ‘package-oriented design’. However, I feel like the examples I have found are designed for larger applications than what I want to start out building.
What sort of design do you use for simple servers? Is there a pattern you keep coming back to?
It’s my first time developing an API server (personal project) and I’m currently following the Standard Package Layout approach discussed by Ben Johnson.
In my opinion, MVC pattern works fine for “simple” servers. However, the way you implement it is important. For example, naming your packages “controllers”, “models” etc. will make it hard to maintain and scaling up. The most common problem you will face in my experience would be avoiding import cycles, since Go doesn’t allow circular imports. Even if you somehow end up avoiding this, I think ensuring different names for every controller/model is tiresome. Check this out. The approach suggested does avoid these basic concerns and is to some extent, if not totally, package oriented too. Feel free to go through the rest of the forum, many design patterns have been discussed with their pros and cons which you may find useful.
Hope it helps!