go-simpler / sloglint

🪵 Ensure consistent code style when using log/slog
https://go-simpler.org/sloglint
Mozilla Public License 2.0
90 stars 5 forks source link

Support Go initialisms for key-naming-case #53

Closed pedantic79 closed 1 month ago

pedantic79 commented 1 month ago

In Go, it is common to have variables named inputURL or userID. This is what the "github.com/ettle/strcase" package calls a "Go initialism".

Let's assume that we have key-naming-case set to camel and we want to log the inputURL value. We might try something like: slog.Info("Getting data from website", slog.String("inputURL", inputURL))

This will be caught by the linter, because it would want the key as inputUrl. However, I want to allow "Go initialisms". Luckily, "github.com/ettle/strcase" does allow this with their strcase.ToGo* functions.

So my request is to add a separate value for key-naming-case corresponding to the current values of camel, pascal, kebab, and snake. These values would call the strcase.ToGo* version of the function instead of strcase.To*. For example go-camel would call strcase.ToGoCamel while camel would continue to call strcase.ToCamel.

pedantic79 commented 1 month ago

Tested this out. strcase doesn't work as I had hoped.