ask

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: BSD-3-Clause Imports: 3 Imported by: 4

README

ask

Ask the user a question, using text.

Build Status GoDoc License Go Report Card

Example use
package main

import (
    "fmt"
    "github.com/xyproto/ask"
)

func main() {
    var (
        yes  bool
        name string
    )
    for !yes {
        name = ask.Ask("What is your name? ")
        yes = ask.YesNo("Your name is "+name+"?", false)
    }
    fmt.Printf("Greetings, %s!\n", name)
}
General info

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ask

func Ask(prompt string) string

Ask a question, wait for textual input followed by a newline.

func ReadLn

func ReadLn() string

ReadLn will read a line from stdin, until \n.

func YesNo added in v1.0.1

func YesNo(question string, noIsDefault bool) bool

YesNo will ask a yes/no question. Will not wait for a newline.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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