Documentation
¶
Overview ¶
Package keyedlit defines an analysis pass that checks that keyed literals' fields are explicitly set.
It currently checks that any field whose name contains 'Timeout' or 'KeepAlive' is explicitly set instead of relying on default values. If the 'strict' flag is set, all exported fields must be specified.
This pass guards against users trusting the default timeout value of 0 which usually indicates an infinite value. Timeouts and KeepAlives should never be set by default and certainly never default to infinity. This pass helps ensure that these values were thoroughly considered in your project.
If the 'strict' flag is specified, this pass ensures that all keyed literals specify all exported field values. This guards against updated dependencies adding new fields that merit consideration.
This pass believes explicit is better: code is read many more times, and often with more at stake, than it is written.
Index ¶
Constants ¶
const Doc = `` /* 298-byte string literal not displayed */
Variables ¶
var Analyzer = &analysis.Analyzer{ Name: "keyedlit", Doc: Doc, Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: run, RunDespiteErrors: true, Flags: func() flag.FlagSet { fs := flag.NewFlagSet("keyedlit", flag.ExitOnError) fs.BoolVar(&strictF, "strict", false, "must specify all exported fields in keyed literals") return *fs }(), }
Functions ¶
This section is empty.
Types ¶
This section is empty.