Admittedly I'm not a huge fan of having:
slog.Info("hello, world", "user", os.Getenv("USER"))
It's a little magical that "user" is a key. So what if you have multiple key-value pairs? Arguably it most likely going to be obvious which is the keys, but having every other value be a key and the rest values seems a little clumsy.I really like Pythons approach where you can have user="value" it makes things a bit more clear.
I think Uber chose a better approach for their Go logging library called Zap [1]
logger.Info("failed to fetch URL",
// Structured context as strongly typed Field values.
zap.String("url", url),
zap.Int("attempt", 3),
zap.Duration("backoff", time.Second),
)
They also have zap.Error(err) which generates the "error" key as a convention.