Closed nikpivkin closed 2 months ago
Hi, thank you for the report. I will take a look.
- Panic when using an attribute assigned to a variable (or returned from a function) when using the slog.Attr constructor.
Fixed in #36.
- 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.
I created separate issues for these. Thanks!
Hi, thanks for this linter! I have encountered some problems while using it.
slog.Attr
constructor:main.go
:import "log/slog"
var MyInt = slog.Int
func main() { slog.Info("Hello, World!", MyInt("foo-foo", 123)) }
slog.Attr
constructor:main.go
:config:
main.go
import ( "fmt" "log/slog" )
var MyInfo = slog.Info
func main() { slog.Info(fmt.Sprintf("a user with id %d has logged in", 42)) // Detected MyInfo(fmt.Sprintf("a user with id %d has logged in", 42)) }
LogAttrs
function (and method) are not detected.main.go
:config: