-
Notifications
You must be signed in to change notification settings - Fork 1
Coding Guidelines
Geoff Greer edited this page Feb 27, 2024
·
7 revisions
- Prefer code that is easy to read and understand to code that is "elegant" or clever.
- When in doubt, leave a comment.
- If you change code near a comment, check to make sure the comment and the code still agree.
- Tests are good. If you are removing or disabling a test, there had better be a good reason for it.
- Avoid lots of nested conditions. Three is probably the most you should ever use. Prefer early returns if possible.
- When constructing or parsing URLs, use golang's url library.
- For http requests, you should probably use baton-sdk's http wrapper library. Here is an example of a connector being ported over to it: https://github.com/ConductorOne/baton-celigo/pull/3.
- Boolean variables should be named
isThing
,hasThing
, etc. - When creating/copying new slices, arrays, use
make([]T, 0, len(expectedSize))
withappend
for maximum safety. Don't use direct index assignment.