old := ferrite.
Duration("OLD", "example duration variable").
Deprecated(
WithDirectReplacement(new),
)
new := ferrite.
Duration("NEW", "example duration variable").
Deprecated()
The goal here is twofold:
- Allow documentation to point to the replacement environment variable
- Surface the value of the new variable via the
old.DeprecatedValue() method
Resolution logic for old.DeprecatedValue() pseudo code
if OLD is defined {
if OLD matches schema of OLD {
return OLD
}
return error
}
if NEW is defined {
if NEW matches schema of OLD {
return NEW
}
// we _could_ optionally return nil here indicating no value is available,
// but I think that would be less useful
return error
}
return nil
The behavior of NEW is unaffected, it is unaware that it is the replacement for OLD.