Help us shape the future of Go! Take the 2026 Go Developer Survey

prompt

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package prompt asks the yes/no confirmation questions of the CLI commands. A question gives up as soon as its context ends — a first Ctrl-C — instead of waiting for an answer that will never come.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAnswer = errors.New("no answer to the confirmation prompt: stdin is closed")

ErrNoAnswer is returned by AskYes when its input ends before any answer is read, as with a closed stdin or one redirected from /dev/null.

Functions

func AskYes

func AskYes(ctx context.Context, in *bufio.Reader, out io.Writer, question string) (bool, error)

AskYes prints question to out and reports whether the next line read from in is "y" or "yes", ignoring case and surrounding spaces. It returns ErrNoAnswer when in ends before a non-empty answer, ctx's error when ctx ends first (the read itself keeps waiting in the background, which is harmless as the process is about to exit), or the read error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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