YAML Time Duration Support in Go
Last time, when one of users asked me "could I set up a 100d
in his yaml file for Go time.Duration
", my first action is why he cannot search the documentation by himself. But then, another problem overwhelmed my mind because actually I'm not sure about it. I don't know it as well.
After seeing the source code, I got the answer. However, the important inspiration here is: "how to make knowledge cohesive", hence the blog comes. In short, you should understand several concepts here:
- whether the time duration is a standard specification?
- does Go implementation allow to parse a string into different type?
- how could it parse?
By enquiring these questions progressively, you can easily recognize how yaml works in a cohesive way instead of remembering some scattered knowledge about it.