Browse Source

etcdctl/ctlv3: remove "strings.Compare == 0"

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
86cee93d6b
2 changed files with 4 additions and 4 deletions
  1. 3 3
      etcdctl/ctlv3/command/printer_simple.go
  2. 1 1
      etcdctl/ctlv3/command/user_command.go

+ 3 - 3
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, <open ended>", 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, <open ended> is revoked from role %s\n", key, role)

+ 1 - 1
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."))
 	}