Logwercase is a Golang linter that report:
- use of uppercase for message in log printer functions
- use of non lower kebab case for WithField key in logrus
Example:
logrus.Print("Hello world") // ✗ bad
logrus.Print("hello world") // ✓ good
logrus.WithField("Hello world", ...) // ✗ bad
logrus.WithField("hello-world", ...) // ✓ good
It supports logrus and stdlib logger.
GO111MODULE=on go get github.com/alexisvisco/logwercase/cmd/logwercase@0.3.2
cd /tmp \
&& rm -rf logwercase \
&& git clone https://github.com/alexisvisco/logwercase \
&& cd logwercase \
&& go build -o logwercase.so -buildmode=plugin plugin/plugin.go \
&& cp logwercase.so /home/$USER/go/bin/ \
&& echo "logwercase.so created and set in " /home/$USER/go/bin/logwercase.so
In your .golangci.yml add these lines:
linters-settings:
custom:
logwercase:
path: /home/$USER/go/bin/logwercase.so
description: Analyze case of log message and WithField keys
original-url: github.com/alexisvisco/logwercase
Change $USER with your user