Refactor context key for logger in main.go
This commit is contained in:
7
main.go
7
main.go
@@ -14,10 +14,6 @@ import (
|
|||||||
"github.com/siteworxpro/top-wallpaper/redis"
|
"github.com/siteworxpro/top-wallpaper/redis"
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextKey string
|
|
||||||
|
|
||||||
const ContextKeyLogger contextKey = "logger"
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
ctx, fn := context.WithCancel(context.Background())
|
ctx, fn := context.WithCancel(context.Background())
|
||||||
@@ -61,7 +57,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx = redis.WithContext(ctx, rc)
|
ctx = redis.WithContext(ctx, rc)
|
||||||
ctx = context.WithValue(ctx, ContextKeyLogger, e.Logger)
|
|
||||||
|
ctx = context.WithValue(ctx, "logger", e.Logger) //nolint:staticcheck
|
||||||
|
|
||||||
go reddit.Fetch(ctx)
|
go reddit.Fetch(ctx)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user