Go newbie: how to organize code

Go newbie: how to organize code

Hello, I'm new to Go, and i have some doubts about how to organize code. I don't know if I understand packages correctly. Let's asume that I'm making a rest api, and I wanna organize my code by functionality. Will be this organization correct?

main.go users/users.go 

users.go will contain all user code: types, handler functions… And in main.go I will import this package as "[fullpath]/users"

Is this correct? If not, what will be the correct way of doing this?

Thanks in advance.

Submitted August 11, 2017 at 05:35PM by dp404e
via reddit http://ift.tt/2fxS7TR


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