setval

package
v0.0.0-...-9c969f2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "setval",
	Doc:  "find Cmder types that are missing a SetVal method",

	Run: func(pass *analysis.Pass) (interface{}, error) {
		cmderTypes := make(map[string]token.Pos)
		typesWithSetValMethod := make(map[string]bool)

		for _, file := range pass.Files {
			for _, decl := range file.Decls {
				funcName, receiverType := parseFuncDecl(decl, pass.TypesInfo)

				switch funcName {
				case "Result":
					cmderTypes[receiverType] = decl.Pos()
				case "SetVal":
					typesWithSetValMethod[receiverType] = true
				}
			}
		}

		for cmder, pos := range cmderTypes {
			if !typesWithSetValMethod[cmder] {
				pass.Reportf(pos, "%s is missing a SetVal method", cmder)
			}
		}

		return nil, nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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