Add string templatizing from Config function #306
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds
ApplyTemplatewhich will take a string and apply the Gotext/templatestring format to the string with theconfig.Configstruct.This allows for the following sort of invocation:
My only real question or thought is that we have generally avoided having trickle up of
errorvalues and have masked some of the errors in the framework to keep calls to just be simple return values. Would it be worth doing this as well? Changing the function signature to:func (conf *Config) ApplyTemplate(name string) stringwould allow for really simple inline usage and application without error checking. The only real downside to that imo would be not having clear error reporting, but that would most likely only bubble up during initial development if say a variable was mistyped.