Ver código fonte

Convert bool command args to "0" and "1".

Gary Burd 13 anos atrás
pai
commit
7adc665b94
2 arquivos alterados com 11 adições e 3 exclusões
  1. 6 0
      redis/conn.go
  2. 5 3
      redis/redis.go

+ 6 - 0
redis/conn.go

@@ -223,6 +223,12 @@ func (c *conn) Send(cmd string, args ...interface{}) error {
 			err = c.writeString(arg)
 		case []byte:
 			err = c.writeBytes(arg)
+		case bool:
+			if arg {
+				err = c.writeString("1")
+			} else {
+				err = c.writeString("0")
+			}
 		case nil:
 			err = c.writeString("")
 		default:

+ 5 - 3
redis/redis.go

@@ -33,9 +33,11 @@
 //
 //  Do(commandName string, args ...interface{}) (reply interface{}, err error)
 //
-// Arguments of type string and []byte are sent to the server as is. All other
-// types are formatted using the fmt.Fprint function. Command replies are
-// represented using the following Go types:
+// Arguments of type string and []byte are sent to the server as is. The value
+// false is converted to "0" and the value true is converted to "1". The value
+// nil is converted to "". All other values are converted to a string using the
+// fmt.Fprint function. Command replies are represented using the following Go
+// types:
 //
 //  Redis type          Go type
 //  error               redis.Error