Skip to content

Instantly share code, notes, and snippets.

@alex-fedorov
Created September 7, 2015 09:58
Show Gist options
  • Save alex-fedorov/ac01b5dcc2b08a547b4a to your computer and use it in GitHub Desktop.
Save alex-fedorov/ac01b5dcc2b08a547b4a to your computer and use it in GitHub Desktop.

Code quality proposal for Golang

Maintaining Single Responsibility Principle

When creating a package, please create a README.md for it with its name and short explanation of its responsibility. Then each time you add/modify any functionality you can refer to README.md and see if it is suitable to put it in this package or it needs to have its own package.

When creating a file inside of package, please put short comment in the beginning of the file what it should contain, what is the job of this submodule.

If you think you need to add some functionality badly, and it does not deserve new package, and it is not included in responsibility of this package defined in README.md, then you might try to change responsibility defined in README.md. But be sure not to have too much of responsibility on the package.

Maximum function length

Lets be honest, setting this will provide us with some challenge and will force us to maintain good factored code and each function will be easy to read and understand in seconds, instead of minutes.

How about: 10.

Maximum submodule (read: one .go file) length

The same thing, it will force us to have more granular and meaningful components.

How about: 150.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment