sloglint is a Go linter for enforcing consistent style in code that uses the standard library’s log/slog. You can enable it in golangci-lint, then configure policies for logger choice, context-aware calls, messages, arguments, and key names. Its module documentation identifies v0.12.0, published April 19, 2026.
How to add sloglint to a Go project
The project recommends enabling sloglint through golangci-lint. Add it to the linter list in your golangci-lint configuration:
linters:
enable:
- sloglint
golangci-lint has included sloglint since v1.55.0, according to its documentation. The same documentation lists autofix support. Review any proposed changes before accepting them, especially where a fix could affect a logging call’s structure or meaning.
If you do not want to run it through golangci-lint, the project also documents downloading a prebuilt binary from its Releases page. The available installation and configuration details are documented by the sloglint module, the golangci-lint project, and its linter documentation.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitches#1 Best Overall
What sloglint can enforce
sloglint covers several independent decisions. A team can enable only the checks it wants, or combine them into a stricter convention.
| Area | Available checks | Example of what the policy changes |
|---|---|---|
| Logger and method choice | no-global, context |
Flag use of a package-level logger, or require context-aware logging methods where configured. |
| Messages | static-msg, msg-style |
Require a string literal or constant rather than a dynamically formatted message; choose lowercase or capitalized message style. |
| Arguments | no-mixed-args, kv-only, attr-only, args-on-sep-lines |
Prevent mixing key-value pairs and slog.Attr values, require one argument form, or put arguments on separate lines. |
| Keys | no-raw-keys, allowed-keys, forbidden-keys, key-naming-case |
Require keys to use constants, restrict or prohibit particular names, and standardize naming as snake_case, kebab-case, camelCase, or PascalCase. |
| Custom logging functions | custom-funcs |
Describe logging wrappers so message, argument, and key checks can also apply to them. |
For example, with global-logger and context checks enabled, slog.Info("a user has logged in") can be flagged for using the global logger and for not using InfoContext. A dynamic message such as slog.Info(fmt.Sprintf("a user with id %d has logged in", 42)) can be flagged when static messages are required. A call combining key-value arguments with an attribute, such as slog.Info("login", "user_id", 42, slog.String("method", "password")), can be flagged when mixed arguments are prohibited.
Choose a useful team policy
The configuration controls are independent; settle the conventions that matter to your codebase before making the checks mandatory. golangci-lint’s sloglint documentation lists the available controls and their autofix support.
- Decide what “global logger” means for your project. Choose whether to prohibit all package-level loggers or only use of the default logger.
- Make context requirements match your APIs. Decide whether context-aware methods are expected everywhere, or only in functions where a context is available.
- Set a message convention. Choose whether messages must be static, and whether they use lowercase or capitalized wording.
- Pick one argument style. Decide whether calls should use key-value pairs or
slog.Attrvalues, and whether arguments should be split across lines. - Define a key policy. Choose a naming case and decide whether to require constants or maintain allowed and forbidden key lists.
- Include wrappers if the project uses them. Configure
custom-funcsfor custom logging functions that should follow the same rules as direct slog calls.
Use sloglint for consistency, not as a substitute for judgment
sloglint helps make logging conventions visible and repeatable in code review and CI. Its checks address style and call patterns; the documented sources do not establish adoption, performance gains, or a reduction in defects. Treat autofixes as suggestions to inspect rather than evidence that a logging change is automatically correct.
The most practical starting point is to enable the linter, agree on a small set of conventions, and expand the rules when the team can apply them consistently. In particular, avoid requiring context-aware methods in places where no context exists, and configure custom wrappers if direct-call rules would otherwise leave part of the project unchecked.
Quick Recap
Best Value
Rank #4
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.




