Closed twelvelabs closed 1 year ago
What operating system and terminal are you using?
An example that showcases the bug.
package main import ( "fmt" "strings" "github.com/AlecAivazis/survey/v2" ) func main() { qs := []*survey.Question{ { Prompt: &survey.Input{ Message: "Name", }, Transform: survey.TransformString(strings.TrimSpace), }, } name := "" _ = survey.Ask(qs, &name) fmt.Println("Hello,", name) }
Ran the above and submitted:
Skip
What did you expect to see?
[~/tmp] $ go run main.go ? Name Skip Hello, Skip
What did you see instead?
The transformed answer is passed to the prompt on Cleanup(), but appears to be ignored in favor of the input's existing answer:
Cleanup()
https://github.com/AlecAivazis/survey/blob/bf4b865e6c271af51ee152a74e41a037d1f8b013/input.go#L211
Changing that to ans := val.(string) seems to fix the issue. I'll try writing a test case and submit a PR.
ans := val.(string)
What operating system and terminal are you using?
An example that showcases the bug.
Ran the above and submitted:
What did you expect to see?
What did you see instead?
The transformed answer is passed to the prompt on
Cleanup()
, but appears to be ignored in favor of the input's existing answer:https://github.com/AlecAivazis/survey/blob/bf4b865e6c271af51ee152a74e41a037d1f8b013/input.go#L211
Changing that to
ans := val.(string)
seems to fix the issue. I'll try writing a test case and submit a PR.