slogkv

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 6 Imported by: 0

README

Documentation

Overview

Package slogkv provides a go/analysis analyzer enforcing the gomatic structured- logging standard: a leveled slog call (slog.Info/Warn/Error/Debug, or the same methods on a *slog.Logger) passes its attributes as constant-string key/value pairs — an even number of trailing arguments whose keys are constant strings.

Calls that pass any slog.Attr argument (or an alias of it) are intentionally not checked: mixing pre-built attributes with loose pairs is a valid, harder-to-verify shape, so the analyzer skips it rather than risk a false positive. Spread calls (slog.Info(msg, kvs...)) are likewise skipped — the spread contents are not statically knowable. Dot-imported calls and method expressions ((*slog.Logger).Info(l, ...)) are checked; method values (f := slog.Info; f(...)) are out of scope, because once the function is bound to a plain variable the call site no longer names a slog entrypoint.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "slogkv",
	Doc:      "reports leveled slog calls whose key/value arguments are unpaired or use a non-constant key",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      run,
}

Analyzer reports malformed key/value arguments to leveled slog calls.

View Source
var Registration = goyze.Registration{
	Name:       "slogkv",
	Categories: []goyze.Category{"logging"},
	URL:        "https://docs.gomatic.dev/yze/slogkv",
	Analyzer:   Analyzer,
}

Registration declares this analyzer to the yze framework.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
yze-go-slogkv command
Command yze-go-slogkv runs the slogkv analyzer as a standalone go/analysis checker (text and -json output, and usable as a `go vet -vettool`).
Command yze-go-slogkv runs the slogkv analyzer as a standalone go/analysis checker (text and -json output, and usable as a `go vet -vettool`).

Jump to

Keyboard shortcuts

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