choice

package
v0.1.83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadChoice = errors.New("bad choice")

ErrBadChoice defines an error that represents an invalid choice made by the user.

Functions

func Choose

func Choose[E any](choices []E) (choice bool, res E, err error)

Choose function allows the user to make a choice from the given options with no default value.

func ChooseWithDefault

func ChooseWithDefault[E any](choices []E, def int) (choice bool, res E, err error)

ChooseWithDefault function allows the user to make a choice from the given options with an optional default value.

func Menu[E any](choices []E, showQuit bool) string

Menu function is used to generate a string representation of the menu, associating choices with numbers.

Types

type Description

type Description interface {
	Description() string
}

Description interface defines a method for obtaining the description of a choice.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL