Repository navigation
Releases
Releases · vasilesk/efmt
v1.1.0
Highlights
-
Zero dependencies.
samber/lohas been replaced with the standard library. -
log/slogintegration. The newefmt.Attrs(err)returns the attached values as[]slog.Attr, deduplicated and in a stable order:attrs := append(efmt.Attrs(err), slog.Any("error", err)) logger.LogAttrs(ctx, slog.LevelError, "request failed", attrs...)
Bug fixes
- Values from joined errors are no longer lost. Values are now collected from the whole error tree, including
errors.Joinandfmt.Errorfwith several%wverbs. The traversal order is the same as inerrors.Is. Value[T]respects key shadowing. Before, if the outermost value for a key had a different type,Value[T]searched inner errors and could return a value thatValuesreports as overridden. Now it uses the same precedence asValuesand returnsfalseon a type mismatch.NewandWrapcopy the key-value slice. Before, changing a slice after passing it askvs...silently changed the error that had already been created.
Documentation
- Package documentation, with the key precedence rules described.
- Testable examples, rendered on pkg.go.dev.
- README sections on
slog, key precedence and compatibility with theerrorspackage.
Upgrade note
KeyValue is now a struct defined in efmt instead of an alias for lo.Entry[string, any]. Code that uses efmt.KV, .Key and .Value is not affected. Code that used efmt.KeyValue and lo.Entry interchangeably (for example, lo.FromEntries(efmt.ValuePairs(err))) needs a conversion or a switch to efmt.Values.
Full Changelog: v1.0.0...v1.1.0