sloglint is a Go linter for enforcing consistent style around the standard-library log/slog package. Enable it in golangci-lint to check logger usage, context-aware calls, message format, argument style, and key naming—and to apply supported fixes automatically.
What sloglint does
sloglint (module version v0.12.0, published April 19, 2026, by go-simpler) analyzes calls to log/slog and can apply the same policies to custom logging wrappers. Its purpose is consistency: teams decide how logging should look, and the linter flags code that deviates.
It does not measure logging performance, reliability, adoption, or defect rates; authoritative project material publishes no such statistics.
Install it through golangci-lint
The recommended setup is to enable the linter in your repository’s golangci-lint configuration:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
linters:
enable:
- sloglint
golangci-lint has included sloglint since v1.55.0. The official project also publishes prebuilt binaries on its Releases page for standalone use, but the golangci-lint integration is usually easier to standardize in local development and CI.
Rules you can enforce
Logger and context usage
no-globalcontrols use of package-level or default global loggers.contextcan require context-aware methods such asInfoContextwhen a context is available.
For example, slog.Info("a user has logged in") may be reported as a global-logger call and, when context enforcement is enabled, as a call that should use InfoContext.
Message text
static-msgrejects dynamically built messages when a literal or constant should be used.msg-stylestandardizes capitalization, such as lowercased or capitalized messages.
This catches code such as slog.Info(fmt.Sprintf("a user with id %d has logged in", 42)) when dynamic messages are disallowed. Structured values should generally be logged as attributes rather than interpolated into the message.
Arguments and attributes
no-mixed-argsprohibits mixing key-value pairs withslog.Attrvalues in one call.kv-onlyrequires key-value pairs.attr-onlyrequires attributes.args-on-sep-linesrequires arguments to appear on separate lines.
A call that combines "user_id", 42 with slog.String(...) can therefore fail the no-mixed-args rule. Choose one argument form for your codebase and document exceptions for wrappers or generated code.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Keys
no-raw-keyscan require constants instead of inline key strings.allowed-keysrestricts keys to an allow-list.forbidden-keysblocks names that are ambiguous, sensitive, or deprecated.key-naming-caseenforcessnake_case,kebab-case,camelCase, orPascalCase.
Key policy is especially useful for logs consumed by dashboards, alerts, and search tools: the same field should not appear under several spellings.
Custom logging functions
custom-funcs describes project-specific logging functions so message, argument, and key checks also apply to wrappers around slog. Add wrappers only after their signatures and argument semantics are stable; otherwise a configuration can create noisy or misleading diagnostics.
Rank #4
Choose a team policy before enabling strict checks
A useful baseline answers these questions explicitly:
- Are all package-level loggers prohibited, or only use of the default logger?
- Are context-aware methods required everywhere, or only in functions that have a context in scope?
- Must messages be static? If so, are they lowercased or capitalized?
- Will calls use key-value pairs,
slog.Attr, or one consistent form? - Should keys be constants, limited to an allow-list, blocked by a deny-list, and normalized to one naming case?
- Which wrapper functions need entries in
custom-funcs?
Decide these conventions before turning on every rule. A policy that matches your existing logging API is easier to adopt than a strict configuration that forces broad, unrelated rewrites.
Best Value
Example configuration shape
golangci-lint exposes the following sloglint controls. Values for naming and lists should reflect your repository’s convention:
linters-settings:
sloglint:
no-global: true
context: "scope"
static-msg: true
msg-style: "lowercased"
no-mixed-args: true
kv-only: true
args-on-sep-lines: true
no-raw-keys: true
allowed-keys:
- request_id
- user_id
forbidden-keys:
- password
key-naming-case: "snake_case"
custom-funcs:
- "pkg/logx.Info"
Option names and supported values are version-sensitive. Check the golangci-lint configuration for the version installed by your project before copying a setting, particularly the value used for context and the syntax for custom functions.
Autofix and CI workflow
golangci-lint marks sloglint as supporting autofix for applicable diagnostics. Use that capability on a branch, review the resulting diff, and then run the full test suite: an automated edit can satisfy style while still changing a log call’s readability or behavior.
- Pin the golangci-lint version used by developers and CI.
- Enable
sloglintwith a small, agreed baseline. - Run the linter locally and fix or explicitly configure existing violations.
- Use the linter’s autofix mode only for diagnostics your team has reviewed.
- Make the same configuration a required CI check so new code cannot reintroduce drift.
- Expand rules in separate changes, reviewing log volume, field compatibility, and wrapper behavior each time.
How sloglint compares with manual review
| Approach | Rule coverage | Strictness | Autofix | CI integration | Custom wrappers |
|---|---|---|---|---|---|
| sloglint in golangci-lint | Logger/context calls, messages, arguments, keys, and configured wrappers | Adjustable per option | Supported for applicable diagnostics | Native golangci-lint workflow | Yes, through custom-funcs |
| Manual code review | Depends on each reviewer and checklist | Inconsistent unless heavily documented | No | Not automatic | Possible, but dependent on reviewer knowledge |
| Unconfigured slog usage | No enforced project-wide style | None | No | No policy gate | No systematic coverage |
sloglint is therefore most valuable when a team wants repeatable enforcement rather than another logging abstraction. It checks source style; it does not replace decisions about retention, redaction, sampling, handler configuration, or operational observability.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteLimitations to plan for
- Rules govern source conventions, not whether a log event is useful or safe to emit.
- Overly strict key allow-lists can slow legitimate schema evolution.
- Requiring context-aware methods is only meaningful when the relevant context is available and correctly propagated.
- Wrapper functions must be configured deliberately; otherwise direct
slogcalls may be checked while equivalent wrapper calls are not. - Configuration syntax and behavior can change with golangci-lint and sloglint versions, so pin and review upgrades.
Bottom line
Enable sloglint through golangci-lint, agree on context, message, argument, and key conventions, then enforce the configuration in CI. Its adjustable rules and supported autofixes make it a practical way to keep Go log/slog calls uniform, including selected project-specific logging wrappers.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

