Organizing Go Code

A good practice (not only in go) is to group code into packages by provided functioality (e.g. user, auth, shoppingcart) not by layers (e.g. model, controllers, views). Related code should be placed into one package.

When you start organizing code this way you will notice that cyclic dependencies between packages disapear and number of methods/types that need to be public reduces.

6 Likes