prompt

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package prompt reads answers from the user. On a terminal, it turns off the echo for passwords. When stdin is not a terminal, it reads each answer as one line from stdin, so scripts can pipe the answers in.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoInput = errors.New("no input: stdin closed before the answer")

ErrNoInput means that stdin closed before an answer came.

Functions

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether the file is a terminal.

Types

type Prompter

type Prompter struct {
	// contains filtered or unexported fields
}

Prompter asks questions on stderr and reads the answers from stdin.

func New

func New(in *os.File, out io.Writer) *Prompter

New returns a Prompter for the given stdin and stderr.

func (*Prompter) Line

func (p *Prompter) Line(label string) (string, error)

Line asks for a visible answer.

func (*Prompter) Reader

func (p *Prompter) Reader() io.Reader

Reader returns the buffered stdin. Use it to read the rest of stdin after a prompt, so no buffered bytes get lost.

func (*Prompter) Secret

func (p *Prompter) Secret(label string) (string, error)

Secret asks for an answer without echo.

func (*Prompter) Terminal

func (p *Prompter) Terminal() bool

Terminal reports whether stdin is a terminal.

Jump to

Keyboard shortcuts

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