DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

sloglint: Enforce Consistent Go log/slog Style

sloglint enforces consistent Go log/slog style, with configurable checks for logger use, contexts, messages, arguments, keys, and wrappers.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.Attr values, 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-funcs for custom logging functions that should follow the same rules as direct slog calls.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.