-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Wondering if I'm missing anything or this is by design: I defined a bunch of logging constant keys in a separate logging
package and set no-raw-keys: true
, but I get false positives "raw keys should not be used (sloglint)".
// main.go
package main
import (
"log/slog"
"sloglint-example/logging"
)
func main() {
contentLength := int64(12345)
url := "https://example.com/file"
slog.Info("File downloaded successfully",
slog.Int64(logging.KeyContentLength, contentLength),
slog.String(logging.KeyURL, url),
)
}
// logging/logging.go
package logging
const (
KeyContentLength = "content_length"
KeyURL = "url"
)
linters:
disable-all: true
enable:
- sloglint # Enable only sloglint
linters-settings:
sloglint:
# Enforce not mixing key-value pairs and attributes.
no-mixed-args: true
# Enforce using key-value pairs only (overrides no-mixed-args, incompatible with attr-only).
kv-only: false
# Enforce using attributes only (overrides no-mixed-args, incompatible with kv-only).
attr-only: true
# Enforce using methods that accept a context.
context: scope
# Enforce using static values for log messages.
static-msg: false
# Enforce using constants instead of raw keys.
no-raw-keys: true
# Enforce a single key naming convention.
# Values: snake, kebab, camel, pascal
key-naming-case: snake
# Enforce putting arguments on separate lines.
args-on-sep-lines: true
Expected: No errors
Actual:
main.go:13:2: raw keys should not be used (sloglint)
slog.Info("File downloaded successfully",
^
rgallagher27 and ccoVeilletmzane
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working