github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/test/testdata/sloglint_no_raw_keys.go (about)

     1  //go:build go1.21
     2  
     3  //golangcitest:args -Esloglint
     4  //golangcitest:config_path testdata/configs/sloglint_no_raw_keys.yml
     5  package testdata
     6  
     7  import "log/slog"
     8  
     9  const foo = "foo"
    10  
    11  func Foo(value int) slog.Attr {
    12  	return slog.Int("foo", value)
    13  }
    14  
    15  func test() {
    16  	slog.Info("msg", foo, 1)
    17  	slog.Info("msg", Foo(1))
    18  
    19  	slog.Info("msg", "foo", 1)           // want `raw keys should not be used`
    20  	slog.Info("msg", slog.Int("foo", 1)) // want `raw keys should not be used`
    21  }