AlecAivazis / survey

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

Fix bug when deal with input value of `uint`. #483

Open hustclf opened 1 year ago

hustclf commented 1 year ago

hi, guys, there is a bug when parsing input unit value larger than 255.

here is a example to reproduce the bug.

package main

import (
    "github.com/AlecAivazis/survey/v2"
)

func main() {
    var max uint
    if err := survey.AskOne(&survey.Input{
        Message: "Which is the unit value?",
    }, &max); err != nil {
        panic(err)
    }
    print(max)
}
image

And we should set bitSize to 0 when calling parseUint, which means let the operating system determine the appropriate bitSize.

AlecAivazis commented 1 year ago

Awesome! Thanks for putting this together.

Do you mind adding a test that confirms the behavior?