go.mod: Migrate to golang.org/x/term (#4073)

golang.org/x/crypto/ssh/terminal is deprecated in favor of golang.org/x/term

See https://github.com/caddyserver/caddy/pull/4073/checks?check_run_id=2152150495
Error: SA1019: package golang.org/x/crypto/ssh/terminal is deprecated: this package moved to golang.org/x/term.  (staticcheck)

See https://github.com/caddyserver/caddy/pull/4073/checks?check_run_id=2152228516
Error: SA1019: package golang.org/x/crypto/ssh/terminal is deprecated: this package moved to golang.org/x/term.  (staticcheck)

Test: go test -count=1 './...'
This commit is contained in:
Simão Gomes Viana 2021-03-29 20:39:08 +02:00 committed by GitHub
parent d63d5ae1ce
commit 1c8ea00828
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View file

@ -25,7 +25,7 @@ import (
"github.com/caddyserver/caddy/v2"
caddycmd "github.com/caddyserver/caddy/v2/cmd"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)
func init() {
@ -67,27 +67,27 @@ func cmdHashPassword(fs caddycmd.Flags) (int, error) {
if len(plaintext) == 0 {
fd := int(os.Stdin.Fd())
if terminal.IsTerminal(fd) {
if term.IsTerminal(fd) {
// ensure the terminal state is restored on SIGINT
state, _ := terminal.GetState(fd)
state, _ := term.GetState(fd)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
<-c
_ = terminal.Restore(fd, state)
_ = term.Restore(fd, state)
os.Exit(caddy.ExitCodeFailedStartup)
}()
defer signal.Stop(c)
fmt.Fprint(os.Stderr, "Enter password: ")
plaintext, err = terminal.ReadPassword(fd)
plaintext, err = term.ReadPassword(fd)
fmt.Fprintln(os.Stderr)
if err != nil {
return caddy.ExitCodeFailedStartup, err
}
fmt.Fprint(os.Stderr, "Confirm password: ")
confirmation, err := terminal.ReadPassword(fd)
confirmation, err := term.ReadPassword(fd)
fmt.Fprintln(os.Stderr)
if err != nil {
return caddy.ExitCodeFailedStartup, err