Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eftakhairul/lib-go
Personal handy go libraries
https://github.com/eftakhairul/lib-go
Last synced: about 1 month ago
JSON representation
Personal handy go libraries
- Host: GitHub
- URL: https://github.com/eftakhairul/lib-go
- Owner: eftakhairul
- License: mit
- Created: 2023-12-11T01:48:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-19T21:44:35.000Z (11 months ago)
- Last Synced: 2024-06-21T15:20:05.984Z (7 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lib-go
Personal handy go libraries## slog with Custom Handler
```goReplaceAttr := func(group []string, a slog.Attr) slog.Attr {
if a.Key == "password" {
return slog.Attr{}
}return slog.Attr{Key: a.Key, Value: a.Value}
}
logger.NewJSONLogger(os.Stdout, loger.MyOptions{
Level: slog.LevelDebug,
ReplaceAttr: ReplaceAttr,
})
slog.SetDefault(logger)ctx := ctx.WithValue(context.Background(), "requestID", "something")
logger.InfoContext(ctx, "testing first log message", slog.Attr{Key: "password", Value: "123456"})
```