slog

Imports

Imports #

_ "embed"
"fmt"
"go/ast"
"go/token"
"go/types"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/go/types/typeutil"
"golang.org/x/tools/internal/typesinternal"

Constants & Variables

Analyzer var #

var Analyzer = *ast.UnaryExpr

doc var #

go:embed doc.go

var doc string

key const #

key is an argument position that should hold a string key or an Attr.

const key position = iota

kvFuncs var #

The names of functions and methods in log/slog that take ...any for key-value pairs, mapped to the number of initial args to skip in order to get to the ones that match the ...any parameter. The first key is the dereferenced receiver type name, or "" for a function.

var kvFuncs = map[string]map[string]int{...}

stringType var #

var stringType = *ast.CallExpr

unknown const #

unknown represents that we do not know if position should hold a key or a value.

const unknown

value const #

value is an argument position that should hold a value.

const value

Type Aliases

position type #

A position describes what is expected to appear in an argument position.

type position int

Functions

isAttr function #

func isAttr(t types.Type) bool

isMethodExpr function #

isMethodExpr reports whether a call is to a MethodExpr.

func isMethodExpr(info *types.Info, c *ast.CallExpr) bool

kvFuncSkipArgs function #

If fn is a slog function that has a ...any parameter for key-value pairs, kvFuncSkipArgs returns the number of arguments to skip over to reach the corresponding arguments, and true. Otherwise it returns (0, false).

func kvFuncSkipArgs(fn *types.Func) (int, bool)

run function #

func run(pass *analysis.Pass) (any, error)

shortName function #

shortName returns a name for the function that is shorter than FullName. Examples: "slog.Info" (instead of "log/slog.Info") "slog.Logger.With" (instead of "(*log/slog.Logger).With")

func shortName(fn *types.Func) string

Generated with Arrow