sprig
sprig copied to clipboard
Proposal: add toDuration
I'm using templates to build more complex yaml configuration based on user input without that user input being parsed into go types first. For purpose of calculating with durations I've added this:
"toDuration": func(v string) time.Duration {
d, err := time.ParseDuration(v)
if err != nil {
panic(err)
}
return d
},
Seems this would be a good fit for the type conversion functions.
I would like this as well. I am generating files where the output must be milliseconds, but I would like to read and write using time.Duration
format. For example:
timeout: {{ (toDuration "3m").Milliseconds }}
renders
timeout: 180000
Hello everyone 👋,
I wanted to let you know that this issue has been addressed in the fork of this project at https://github.com/go-sprout/sprout. The fix has been implemented starting from version v0.3.0
.
For those looking for a solution, I recommend checking out the latest releases of the fork. This should help address the issue discussed in this thread.
Thank you!