keyedlit

package
v0.0.0-...-0c3c093 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2019 License: MIT Imports: 7 Imported by: 0

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

View Source
const Doc = `` /* 298-byte string literal not displayed */

Variables

View Source
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.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL