Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Support for fmt.Stringer interface to display structs in Select/MultiSelect #472

Open
metafates opened this issue Nov 24, 2022 · 0 comments
Labels

Comments

@metafates
Copy link

metafates commented Nov 24, 2022

Awesome lib! But I really miss such behaviour, it would make things much easier.

Title says it's all, but just for the reference

type User struct {
	name, surname string
}

func (u *User) String() string {
	return fmt.Sprintf("%s %s", u.name, u.surname)
}

var users = []User{
	{"John", "Doe"},
	{"Sam", "Smith"},
}

func main() {
	var selected User
	survey.AskOne(&survey.Select{
		Message: "Select user",
		Options:   users,
	}, &selected)
}

This feature would make such operations much more convenient and optimised, rather than manually searching for a related data based on string somehow.

Are there any reasons why it's not a thing?

sad cat

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant