Suggestions and Considerations
This lesson lists some useful pieces of advice, tips and things a programmer should consider to program efficiently in Go.
We'll cover the following...
General
Stopping a program in case of error
if err != nil {
fmt.Printf("Program stopping with error %v", err)
os.Exit(1)
}
or:
if err != nil {
panic("ERROR occurred: " + err.Error())
}
Performance best practices and advice
- Use
[]rune
, if possible, instead of strings. - Use slices