This section will briefly talk about some common Go mistakes so that you can avoid them in your programs:
- If you have an error in a Go function, either log it or return it; do not do both unless you have a really good reason to do so.
- Go interfaces define behaviors, not data and data structures.
- Use the io.Reader and io.Writer interfaces because they make your code more extensible.
- Make sure that you pass a pointer to a variable to a function only when needed. The rest of the time, just pass the value of the variable.
- Error variables are not strings; they are error values.
- If you are afraid of making mistakes, you will most likely end up doing nothing useful. So experiment as much as you can.
The following are ...