Ejemplo n.º 1
0
Archivo: user.go Proyecto: cvvs/caddy
// agreeing, pass false. It returns whether the user agreed or not.
func promptUserAgreement(agreementURL string, changed bool) bool {
	if changed {
		fmt.Printf("The Let's Encrypt Subscriber Agreement has changed:\n  %s\n", agreementURL)
		fmt.Print("Do you agree to the new terms? (y/n): ")
	} else {
		fmt.Printf("To continue, you must agree to the Let's Encrypt Subscriber Agreement:\n  %s\n", agreementURL)
		fmt.Print("Do you agree to the terms? (y/n): ")
	}

	reader := bufio.NewReader(stdin)
	answer, err := reader.ReadString('\n')
	if err != nil {
		return false
	}
	answer = strings.ToLower(strings.TrimSpace(answer))

	return answer == "y" || answer == "yes"
}

// stdin is used to read the user's input if prompted;
// this is changed by tests during tests.
var stdin = io.ReadWriter(os.Stdin)

// The name of the folder for accounts where the email
// address was not provided; default 'username' if you will.
const emptyEmail = "default"

// TODO: Use latest
const saURL = "https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf"
Ejemplo n.º 2
0
func makeRWS() io.ReadWriteSeeker { return &RWS{} }
func makeStringer() fmt.Stringer  { return &RWS{} }

// Test correct construction of static empty interface values
var efaces = [...]struct {
	x interface{}
	s string
}{
	{nil, "<nil> <nil>"},
	{1, "int 1"},
	{int(1), "int 1"},
	{Int(int(2)), "main.Int Int=2"},
	{int(Int(3)), "int 3"},
	{[1]int{2}, "[1]int [2]"},
	{io.Reader(io.ReadWriter(io.ReadWriteSeeker(nil))), "<nil> <nil>"},
	{io.Reader(io.ReadWriter(io.ReadWriteSeeker(&RWS{}))), "*main.RWS rws"},
	{makeRWS(), "*main.RWS rws"},
	{map[string]string{"here": "there"}, "map[string]string map[here:there]"},
	{chan bool(nil), "chan bool <nil>"},
	{unsafe.Pointer(uintptr(0)), "unsafe.Pointer <nil>"},
	{(*byte)(nil), "*uint8 <nil>"},
	{io.Writer((*os.File)(nil)), "*os.File <nil>"},
	{(interface{})(io.Writer((*os.File)(nil))), "*os.File <nil>"},
	{fmt.Stringer(Strunger(((*Int)(nil)))), "*main.Int <nil>"},
}

type Int int

func (i Int) String() string { return fmt.Sprintf("Int=%d", i) }
func (i Int) Strung()        {}