survey icon indicating copy to clipboard operation
survey copied to clipboard

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

Open hustclf opened this issue 2 years ago • 1 comments

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.

hustclf avatar Apr 06 '23 14:04 hustclf

Awesome! Thanks for putting this together.

Do you mind adding a test that confirms the behavior?

AlecAivazis avatar May 04 '23 16:05 AlecAivazis