Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
Signed-off-by: tmzane <[email protected]>
  • Loading branch information
tmzane authored Dec 12, 2023
1 parent ed5057e commit 4ed54fa
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ A Go linter that ensures consistent code style when using `log/slog`.
## 📌 About

The `log/slog` API allows two different types of arguments: key-value pairs and attributes.
People may have different opinions about which one is better,
but nobody probably wants to mix them up because it makes the code harder to read:

```go
slog.Info("a user has logged in", "user_id", 42, slog.String("ip_address", "192.0.2.0")) // ugh
```

`sloglint` finds such function calls and checks that all the arguments are either key-value pairs or attributes.
The linter has several options, so you can adjust it to your own code style.
While people may have different opinions about which one is better, most seem to agree on one thing: it should be consistent.
With `sloglint` you can enforce various rules for `log/slog` based on your preferred code style.

## 🚀 Features

Expand Down Expand Up @@ -134,7 +127,8 @@ func UserId(value int) slog.Attr { return slog.Int("user_id", value) }
slog.Info("a user has logged in", UserId(42))
```

> 💡 Such helpers can be automatically generated for you by the [`sloggen`][4] tool. Give it a try too!
> [!TIP]
> Such helpers can be automatically generated for you by the [`sloggen`][4] tool. Give it a try too!

### Key naming convention

Expand Down

0 comments on commit 4ed54fa

Please sign in to comment.