From 86cee93d6b592105f7d30a438480295be2e12fa4 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Mon, 30 Apr 2018 15:11:11 -0700 Subject: [PATCH] etcdctl/ctlv3: remove "strings.Compare == 0" Signed-off-by: Gyuho Lee --- etcdctl/ctlv3/command/printer_simple.go | 6 +++--- etcdctl/ctlv3/command/user_command.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/etcdctl/ctlv3/command/printer_simple.go b/etcdctl/ctlv3/command/printer_simple.go index 99b27b68c..dee958688 100644 --- a/etcdctl/ctlv3/command/printer_simple.go +++ b/etcdctl/ctlv3/command/printer_simple.go @@ -189,12 +189,12 @@ func (s *simplePrinter) RoleGet(role string, r v3.AuthRoleGetResponse) { printRange := func(perm *v3.Permission) { sKey := string(perm.Key) sRangeEnd := string(perm.RangeEnd) - if strings.Compare(sRangeEnd, "\x00") != 0 { + if sRangeEnd != "\x00" { fmt.Printf("\t[%s, %s)", sKey, sRangeEnd) } else { fmt.Printf("\t[%s, ", sKey) } - if strings.Compare(v3.GetPrefixRangeEnd(sKey), sRangeEnd) == 0 { + if v3.GetPrefixRangeEnd(sKey) == sRangeEnd { fmt.Printf(" (prefix %s)", sKey) } fmt.Printf("\n") @@ -240,7 +240,7 @@ func (s *simplePrinter) RoleRevokePermission(role string, key string, end string fmt.Printf("Permission of key %s is revoked from role %s\n", key, role) return } - if strings.Compare(end, "\x00") != 0 { + if end != "\x00" { fmt.Printf("Permission of range [%s, %s) is revoked from role %s\n", key, end, role) } else { fmt.Printf("Permission of range [%s, is revoked from role %s\n", key, role) diff --git a/etcdctl/ctlv3/command/user_command.go b/etcdctl/ctlv3/command/user_command.go index 4df56f720..c243561de 100644 --- a/etcdctl/ctlv3/command/user_command.go +++ b/etcdctl/ctlv3/command/user_command.go @@ -272,7 +272,7 @@ func readPasswordInteractive(name string) string { ExitWithError(ExitBadArgs, fmt.Errorf("failed to ask password: %s.", err2)) } - if strings.Compare(password1, password2) != 0 { + if password1 != password2 { ExitWithError(ExitBadArgs, fmt.Errorf("given passwords are different.")) }