Uber Go Guide #50
Labels
No Label
Dev Ready
Issue Not Ready
Tech Debt
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: simplesystems/go-resources#50
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://github.com/uber-go/guide/blob/master/style.md
Use defer to clean up resources.
Use the time package for handling time. Use duration for durations.
When adding context to returned errors, keep the context succinct by avoiding phrases like "failed to", which state the obvious and pile up as the error percolates up through the stack.
The single return value form of a type assertion will panic on an incorrect type. Therefore, always use the "comma ok" idiom.
Don't panic. Panic/recover is not an error handling strategy.
Avoid Embedding Types in Public Structs.
If using init, make sure it is deterministic. (The precomputed table for ternary bianry words.)
Call one of os.Exit or log.Fatal* only in main(). All other functions should return errors to signal failure.
strconv is faster than fmt.
Group Similar Declarations.
Short and succinct package names.
Reduce Nesting (keep code left).
Put a line between embedded types and others.
Use short
:=
declaration unless declaring the zero value.Reduce scope of variables, especially
err
.Avoid naked parameters.
Use Raw String Literals to Avoid Escaping.
Use Field Names to Initialize Structs.
Use make to initialize maps. This avoids panics when writing to a nil map.