AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 350 forks source link

fix(core): Allow to use `time.Duration` struct fields #240

Closed liranp closed 5 years ago

liranp commented 5 years ago

Description

We are trying to use this package to initialize a time.Duration field but getting an error when the answer is written to the target struct by core/write.go#L189-L190. This PR adds support for struct fields of type time.Duration.

Example

type Options struct {
    Timeout time.Duration
}

survey.Ask([]*survey.Question{{...}}, new(Options))
AlecAivazis commented 5 years ago

Nice! Looks like we have an issue in travis that's preventing your build from passing. I'll try to figure out what's going on so we can get this merged ASAP

AlecAivazis commented 5 years ago

Okay so the latest PR should fix your build problem. Mind rebasing on the latest master?

liranp commented 5 years ago

Done. Thank you!