git » chasquid » commit fcdc49d

chasquid-util: Update ReadPassword dependency

author Alberto Bertogli
2021-10-08 16:36:31 UTC
committer Alberto Bertogli
2021-10-08 22:11:29 UTC
parent 07c133fd15eccf5e8e392c3a34b4d156dc0cdd58

chasquid-util: Update ReadPassword dependency

Today, we use `golang.org/x/crypto/ssh/terminal` to read passwords. That
package is obsolete, replaced with `golang.org/x/term`.

We couldn't move them because term wasn't compatible with Go 1.11 which
was our oldest supported Go version.

Now that we moved to Go 1.15 as the oldest supported version, we can do
the update.

cmd/chasquid-util/chasquid-util.go +3 -6
go.mod +1 -1

diff --git a/cmd/chasquid-util/chasquid-util.go b/cmd/chasquid-util/chasquid-util.go
index 57a12db..feb5f3d 100644
--- a/cmd/chasquid-util/chasquid-util.go
+++ b/cmd/chasquid-util/chasquid-util.go
@@ -21,11 +21,8 @@ import (
 	"blitiri.com.ar/go/chasquid/internal/envelope"
 	"blitiri.com.ar/go/chasquid/internal/normalize"
 	"blitiri.com.ar/go/chasquid/internal/userdb"
+	"golang.org/x/term"
 	"google.golang.org/protobuf/encoding/prototext"
-
-	// TODO: Move to golang.org/x/term once we don't support Go 1.11 anymore,
-	// since this one is deprecated (but still fully functional, so no rush).
-	"golang.org/x/crypto/ssh/terminal"
 )
 
 // Usage to show users on --help or invocation errors.
@@ -182,14 +179,14 @@ func getPassword() string {
 	}
 
 	fmt.Printf("Password: ")
-	p1, err := terminal.ReadPassword(syscall.Stdin)
+	p1, err := term.ReadPassword(syscall.Stdin)
 	fmt.Printf("\n")
 	if err != nil {
 		Fatalf("Error reading password: %v\n", err)
 	}
 
 	fmt.Printf("Confirm password: ")
-	p2, err := terminal.ReadPassword(syscall.Stdin)
+	p2, err := term.ReadPassword(syscall.Stdin)
 	fmt.Printf("\n")
 	if err != nil {
 		Fatalf("Error reading password: %v", err)
diff --git a/go.mod b/go.mod
index 2924f54..7820a0d 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
 	golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
 	golang.org/x/net v0.0.0-20210525063256-abc453219eb5
 	golang.org/x/sys v0.0.0-20210531080801-fdfd190a6549 // indirect
-	golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
+	golang.org/x/term v0.0.0-20210503060354-a79de5458b56
 	golang.org/x/text v0.3.6
 	google.golang.org/protobuf v1.26.0
 )