You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No violation is detected when using the custom slog.Attr constructor:
main.go:
package main
import"log/slog"funcUserId(valueint) slog.Attr { returnslog.Int("user-id", value) }
funcmain() {
slog.Info("a user has logged in", slog.Int("user-id", 42)) // Detectedslog.Info("a user has logged in", UserId(42))
}
The violation is not detected when using the logging function of the assigned variable. This looks like the second case, but I had a quick look at the code and it affects a different part, so I thought I'd mention it. main.go
package main
import (
"fmt""log/slog"
)
varMyInfo=slog.Infofuncmain() {
slog.Info(fmt.Sprintf("a user with id %d has logged in", 42)) // DetectedMyInfo(fmt.Sprintf("a user with id %d has logged in", 42))
}
The LogAttrs function (and method) are not detected.
main.go:
package main
import (
"context""fmt""log/slog"
)
funcmain() {
slog.Info(fmt.Sprintf("a user with id %d has logged in", 42)) // Detectedslog.LogAttrs(context.TODO(), slog.LevelInfo, fmt.Sprintf("a user with id %d has logged in", 42), slog.String("id", "42"))
}
The violation is not detected when using the logging function of the assigned variable.
This is by design. Currently, we only analyze static function calls (i.e. those that are not wrapped in a variable). I'm not sure it is even possible to detect non-static calls. Do you have a use case for those?
No violation is detected when using the custom slog.Attr constructor.
The LogAttrs function (and method) are not detected.
Hi, thanks for this linter! I have encountered some problems while using it.
slog.Attr
constructor:main.go
:config:
slog.Attr
constructor:main.go
:config:
main.go
config:
LogAttrs
function (and method) are not detected.main.go
:config:
The text was updated successfully, but these errors were encountered: