File: example_test.go

package info (click to toggle)
golang-github-bowery-prompt 0.0~git20160808.0.d43c270-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 128 kB
  • ctags: 186
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 476 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package prompt_test

import (
	"net/mail"

	"github.com/Bowery/prompt"
	"golang.org/x/crypto/bcrypt"
)

func ExamplePassword() ([]byte, error) {
	clear, err := prompt.Password("Password")
	if err != nil {
		return nil, err
	}

	return bcrypt.GenerateFromPassword([]byte(clear), bcrypt.DefaultCost)
}

func ExampleBasic() (string, error) {
	email, err := prompt.Basic("Email", true)
	if err != nil {
		return "", err
	}

	_, err = mail.ParseAddress(email)
	return email, err
}