mirror of
https://github.com/juanfont/headscale.git
synced 2026-01-23 02:24:10 +00:00
Some checks are pending
Build / build-nix (push) Waiting to run
Build / build-cross (GOARCH=amd64 GOOS=darwin) (push) Waiting to run
Build / build-cross (GOARCH=amd64 GOOS=linux) (push) Waiting to run
Build / build-cross (GOARCH=arm64 GOOS=darwin) (push) Waiting to run
Build / build-cross (GOARCH=arm64 GOOS=linux) (push) Waiting to run
Check Generated Files / check-generated (push) Waiting to run
Tests / test (push) Waiting to run
24 lines
496 B
Go
24 lines
496 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// YesNo takes a question and prompts the user to answer the
|
|
// question with a yes or no. It appends a [y/n] to the message.
|
|
// The question is written to stderr so that content can be redirected
|
|
// without interfering with the prompt.
|
|
func YesNo(msg string) bool {
|
|
fmt.Fprint(os.Stderr, msg+" [y/n] ")
|
|
|
|
var resp string
|
|
fmt.Scanln(&resp)
|
|
resp = strings.ToLower(resp)
|
|
switch resp {
|
|
case "y", "yes", "sure":
|
|
return true
|
|
}
|
|
return false
|
|
}
|