Structuring your Go Application

When we are learning Go, we tend to do it just in a single file thinking of it at a very small scale. But in practice, when we are building production quality stuffs, the first thing we’ve to start doing it is making multiple files, organizing them in folders. So, its the first thing we do, but its the last thing we ever talk about.

The structure of a program is all about – How can you quickly go to the place you need in order to work on the thing you need to work on? Good structures, good file names, good folder names – this stuff all helps with that process.

From Go language, there are some constraints like how you create folders because everything inside a folder is grouped logically as a package. Nested folders don’t really do anything special in Go as they don’t represent nested packages or anything.

One of the way could be to just start with one flat structure, and then later, once there are more code then you try separating those. So, let the structure emerge from the work you are doing, rather than trying to imagine it upfront.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: