go-sprout / sprout

From sprig to sprout - Useful template functions for Go templates with steroids
https://sprout.atom.codes
MIT License
86 stars 4 forks source link

docs: show conversion from duration to seconds #44

Closed cbandy closed 1 month ago

cbandy commented 2 months ago

Description

I use Go templates to produce machine-readable files, and one of the challenges I face is producing amounts of time as seconds and milliseconds. I want to write values like "5 minutes" or "30 seconds" for the benefit of file maintainers and have a computer do the math to turn them into numbers.

The toDuration function satisfies my use case and seems valuable to show in the documentation.

Changes

One more example for the toDuration function.

Fixes

Checklist

Additional Information

This example matches this test: https://github.com/go-sprout/sprout/blob/aca5c32cd0f8340e64998aa718dee2b3564717d4/conversion_functions_test.go#L130