Documentation
¶
Overview ¶
Command checkstate audits the library package for hidden state and unplanned panics. It type-checks the non-test files that the current build selects in the given directory and requires that:
- every package-level variable is unexported and has a value type (basic, or arrays and structs of value types), so it cannot be a knob another package sets or a reference another value shares;
- no expression anywhere in the package, including package-level initializers and function literals, writes such a variable: no assignment, increment, range assignment, address-of, aliasing slice of an array, pointer-receiver method call or copy/append/delete/clear through it;
- there is no init function;
- panic appears only inside functions named Must followed by an upper-case letter (MustParse, which is meant for literals).
Names are resolved with go/types, so shadowing and aliasing through local declarations are handled exactly rather than by spelling.
Click to show internal directories.
Click to hide internal directories.