Browse Source

Minor comment tweaks.

Gary Burd 13 years ago
parent
commit
82e51ce44d
8 changed files with 18 additions and 46 deletions
  1. 4 4
      redis/doc.go
  2. 4 3
      redis/pool.go
  3. 1 1
      redis/pubsub_test.go
  4. 1 30
      redis/reply.go
  5. 5 5
      redis/scan.go
  6. 1 1
      redis/script.go
  7. 1 1
      redisx/example.go
  8. 1 1
      redisx/util.go

+ 4 - 4
redis/doc.go

@@ -45,13 +45,13 @@
 //  status              string
 //  bulk                []byte or nil if value not present.
 //  multi-bulk          []interface{} or nil if value not present.
-// 
+//
 // Applications can use type assertions or type switches to determine the type
 // of a reply.
 //
 // Pipelining
 //
-// Connections support pipelining using the Send, Flush and Receive methods. 
+// Connections support pipelining using the Send, Flush and Receive methods.
 //
 //  Send(commandName string, args ...interface{}) error
 //  Flush() error
@@ -92,7 +92,7 @@
 // concurrent access is allowed.
 //
 // Publish and Subscribe
-//  
+//
 // Use the Send, Flush and Receive methods to implement Pub/Sub subscribers.
 //
 //  c.Send("SUBSCRIBE", "example")
@@ -104,7 +104,7 @@
 //      }
 //      // process pushed message
 //  }
-// 
+//
 // The PubSubConn type wraps a Conn with convenience methods for implementing
 // subscribers. The Subscribe, PSubscribe, Unsubscribe and PUnsubscribe methods
 // send and flush a subscription management command. The receive method

+ 4 - 3
redis/pool.go

@@ -47,14 +47,14 @@ var errPoolClosed = errors.New("redigo: connection pool closed")
 //                  }
 //                  if err := c.Do("AUTH", password); err != nil {
 //                      c.Close()
-//                      return nil, err    
+//                      return nil, err
 //                  }
 //                  return c, err
 //              },
 //          }
 //
 // This pool has a maximum of three connections to the server specified by the
-// variable "server". Each connection is authenticated using a password. 
+// variable "server". Each connection is authenticated using a password.
 //
 // A request handler gets a connection from the pool and closes the connection
 // when the handler is done:
@@ -89,7 +89,7 @@ type idleConn struct {
 }
 
 // NewPool returns a pool that uses newPool to create connections as needed.
-// The pool keeps a maximum of maxIdle idle connections. 
+// The pool keeps a maximum of maxIdle idle connections.
 func NewPool(newFn func() (Conn, error), maxIdle int) *Pool {
 	return &Pool{Dial: newFn, MaxIdle: maxIdle}
 }
@@ -177,6 +177,7 @@ func (c *pooledConnection) get() error {
 
 func (c *pooledConnection) Close() (err error) {
 	if c.c != nil {
+		c.c.Do("")
 		if c.c.Err() != nil {
 			err = c.c.Close()
 		} else {

+ 1 - 1
redis/pubsub_test.go

@@ -68,7 +68,7 @@ func ExamplePubSubConn() {
 		}
 	}()
 
-	// This goroutine manages subscriptions for the connection. 
+	// This goroutine manages subscriptions for the connection.
 	go func() {
 		defer wg.Done()
 

+ 1 - 30
redis/reply.go

@@ -22,35 +22,6 @@ import (
 
 var ErrNil = errors.New("redigo: nil returned")
 
-// xValues is deprecated. Use Scan instead.
-func xValues(multiBulk []interface{}, values ...interface{}) ([]interface{}, error) {
-	if len(multiBulk) < len(values) {
-		return nil, errors.New("redigo Values: short multibulk")
-	}
-	var err error
-	for i, value := range values {
-		bulk := multiBulk[i]
-		if bulk != nil {
-			switch value := value.(type) {
-			case *string:
-				*value, err = String(bulk, nil)
-			case *int:
-				*value, err = Int(bulk, nil)
-			case *bool:
-				*value, err = Bool(bulk, nil)
-			case *[]byte:
-				*value, err = Bytes(bulk, nil)
-			default:
-				panic("Value type not supported")
-			}
-			if err != nil {
-				break
-			}
-		}
-	}
-	return multiBulk[len(values):], err
-}
-
 // Int is a helper that converts a command reply to an integer. If err is not
 // equal to nil, then Int returns 0, err. Otherwise, Int converts the
 // reply to an int as follows:
@@ -140,7 +111,7 @@ func Bytes(reply interface{}, err error) ([]byte, error) {
 //
 //  Reply type      Result
 //  integer         value != 0, nil
-//  bulk            strconv.ParseBool(reply) 
+//  bulk            strconv.ParseBool(reply)
 //  nil             false, ErrNil
 //  other           false, error
 func Bool(reply interface{}, err error) (bool, error) {

+ 5 - 5
redis/scan.go

@@ -184,16 +184,16 @@ func convertAssign(d interface{}, s interface{}) (err error) {
 	return
 }
 
-// Scan copies from the multi-bulk src to the values pointed at by dest. 
-// 
+// Scan copies from the multi-bulk src to the values pointed at by dest.
+//
 // The values pointed at by test must be a numeric type, boolean, string,
 // []byte, interface{} or a slice of these types. Scan uses the standard
-// strconv package to convert bulk values to numeric and boolean types. 
+// strconv package to convert bulk values to numeric and boolean types.
 //
 // If a dest value is nil, then the corresponding src value is skipped.
 //
 // If the multi-bulk value is nil, then the corresponding dest value is not
-// modified. 
+// modified.
 //
 // To enable easy use of Scan in a loop, Scan returns the slice of src
 // following the copied values.
@@ -233,7 +233,7 @@ func compileStructSpec(t reflect.Type, depth map[string]int, index []int, ss *st
 		case f.PkgPath != "":
 			// Ignore unexported fields.
 		case f.Anonymous:
-			// TODO: Handle pointers. Requires change to decoder and 
+			// TODO: Handle pointers. Requires change to decoder and
 			// protection against infinite recursion.
 			if f.Type.Kind() == reflect.Struct {
 				compileStructSpec(f.Type, depth, append(index, i), ss)

+ 1 - 1
redis/script.go

@@ -74,7 +74,7 @@ func (s *Script) SendHash(c Conn, keysAndArgs ...interface{}) error {
 	return c.Send("EVALSHA", s.args(s.hash, keysAndArgs)...)
 }
 
-// Send evaluates the script without waiting for the reply. 
+// Send evaluates the script without waiting for the reply.
 func (s *Script) Send(c Conn, keysAndArgs ...interface{}) error {
 	return c.Send("EVAL", s.args(s.src, keysAndArgs)...)
 }

+ 1 - 1
redisx/example.go

@@ -12,7 +12,7 @@
 // License for the specific language governing permissions and limitations
 // under the License.
 
-// +build ignore 
+// +build ignore
 
 package main
 

+ 1 - 1
redisx/util.go

@@ -43,7 +43,7 @@ func compileStructSpec(t reflect.Type, depth map[string]int, index []int, ss *st
 		case f.PkgPath != "":
 			// Ignore unexported fields.
 		case f.Anonymous:
-			// TODO: Handle pointers. Requires change to decoder and 
+			// TODO: Handle pointers. Requires change to decoder and
 			// protection against infinite recursion.
 			if f.Type.Kind() == reflect.Struct {
 				compileStructSpec(f.Type, depth, append(index, i), ss)