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

     1  //go:build go1.21
     2  
     3  //golangcitest:args -Esloglint
     4  //golangcitest:config_path testdata/configs/sloglint_key_naming_case.yml
     5  package testdata
     6  
     7  import "log/slog"
     8  
     9  const (
    10  	snakeKey = "foo_bar"
    11  	kebabKey = "foo-bar"
    12  )
    13  
    14  func test() {
    15  	slog.Info("msg", "foo_bar", 1)
    16  	slog.Info("msg", snakeKey, 1)
    17  	slog.Info("msg", slog.Int("foo_bar", 1))
    18  	slog.Info("msg", slog.Int(snakeKey, 1))
    19  
    20  	slog.Info("msg", "foo-bar", 1)           // want `keys should be written in snake_case`
    21  	slog.Info("msg", kebabKey, 1)            // want `keys should be written in snake_case`
    22  	slog.Info("msg", slog.Int("foo-bar", 1)) // want `keys should be written in snake_case`
    23  	slog.Info("msg", slog.Int(kebabKey, 1))  // want `keys should be written in snake_case`
    24  }