Skip to content

Coding standards

kstola2 edited this page Jun 28, 2019 · 5 revisions

Syntax

We use camel-case for variable and function names.

Documentation

Errors

Returning custom errors from your functions is a way of identifying the root of undesired behavior. If there is a case in your function that checks for errors, make sure to return it with the following format:

if err != nil {
    errors.New("Failed to do the thing: " + err.Error())
}

When error handling in a test, the format is a little different:

if err != nil {
    t.Errorf("This isn't what I wanted because: %v", err)
}

This will allow us to build our own stack trace which is great for debugging.

Tests

Clone this wiki locally