New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/cbrgm/dialog

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/cbrgm/dialog

  • v0.0.0-20190904233643-b231f9b7fcf6
  • Source
  • Go
  • Socket score

Version published
Created
Source

dialog

Godoc Reference Build Status Go Report Card

Go module to parse input data and return it as a Go basic type

Usage

package main

import (
	"fmt"
	"github.com/cbrgm/dialog"
	"os"
)

func main() {
	
	// Ask for username from stdin, default "foo bar", don't skip
	
	fmt.Println("Please enter your name:")
	name, err := dialog.AskForString(os.Stdin, "foo bar", false)
	if err != nil {
		print(err)
	}
	
	// Ask for status from stdin, default "true", don't skip
	// Blocks until the user enters eiter y (yes), n (no), or q (quit)
	
	fmt.Println("Are you hungry? [y/n/q]:")
	hungry, err := dialog.AskForBool(os.Stdin, true, false)
	if err != nil {
		print(err)
        }
    
	// Ask for going out from stdin, block until user enters 'yes' or 'no', max 3 attempts, don't skip
	// If user hits Strg+C, false is returned
	
	fmt.Println("Pizza!? [y/n]:")
	pizza := dialog.AskForConfirmation(os.Stdin, 3, false)
	if err != nil {
	    print(err)
        }
	
	fmt.Printf("%s, is hungry (%t), wants to eat pizza (%t)!", name, hungry, pizza)
}

Installation

$ go get github.com/cbrgm/dialog

Credit & License

dialog is open-source and is developed under the terms of the MIT.

Maintainer of this repository is:

Please refer to the git commit log for a complete list of contributors.

Contributing

See the Contributing Guide.

FAQs

Package last updated on 04 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc