Regarding the WithFunc, it was added just for more flexibility should a field value depends on context or anything else.
YAGNI. Can you give a specific example of a problem it solves? I can give an example of a problem it introduces: you've now got a way to get into an infinite loop without really realising it.
fields.WithFunc("foo", func(ctx context.Context) interface{} {
return util.getValueOfFoo(ctx)
}).Onto(ctx)
// somewhere else, some utility package etc
func getValueOfFoo(ctx context.Context) string {
log.From(ctx).Info("getting value of foo") // infinite recursion here
return "bar"
}
YAGNI. Can you give a specific example of a problem it solves? I can give an example of a problem it introduces: you've now got a way to get into an infinite loop without really realising it.
Originally posted by @jamesrom in https://github.com/anz-bank/pkg/issues/18#issuecomment-581704464