Imports #
"fmt"
"go/ast"
"go/types"
"strings"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/internal/typeparams"
"fmt"
"go/ast"
"go/types"
"strings"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/internal/typeparams"
var Analyzer = *ast.UnaryExpr
const Doc = `check for unkeyed composite literals
This analyzer reports a diagnostic for composite literals of struct
types imported from another package that do not use the field-keyed
syntax. Such literals are fragile because the addition of a new field
(even if unexported) to the struct will cause compilation to fail.
As an example,
err = &net.DNSConfigError{err}
should be replaced by:
err = &net.DNSConfigError{Err: err}
`
unkeyedLiteral is a white list of types in the standard packages that are used with unkeyed literals we deem to be acceptable.
var unkeyedLiteral = map[string]bool{...}
var whitelist = true
func init()
isLocalType reports whether typ belongs to the same package as pass. TODO(adonovan): local means "internal to a function"; rename to isSamePackageType.
func isLocalType(pass *analysis.Pass, typ types.Type) bool
runUnkeyedLiteral checks if a composite literal is a struct literal with unkeyed fields.
func run(pass *analysis.Pass) (interface{}, error)
Generated with Arrow