Przeglądaj źródła

Improve documentation.

Gary Burd 12 lat temu
rodzic
commit
12c718e9e0
2 zmienionych plików z 16 dodań i 11 usunięć
  1. 6 8
      redis/doc.go
  2. 10 3
      redis/scan.go

+ 6 - 8
redis/doc.go

@@ -81,14 +81,12 @@
 //  r, err := c.Do("EXEC")
 //  fmt.Println(r) // prints [1, 1]
 //
-// Thread Safety
-//
-// The connection Send and Flush methods cannot be called concurrently with
-// other calls to these methods. The connection Receive method cannot be called
-// concurrently  with other calls to Receive. Because the connection Do method
-// uses Send, Flush and Receive, the Do method cannot be called concurrently
-// with Send, Flush, Receive or Do. Unless stated otherwise, all other
-// concurrent access is allowed.
+// Concurrency
+//
+// Connections support a single concurrent caller to the write methods (Send,
+// Flush) and a single concurrent caller to the read method (Receive). Because
+// Do method combines the functionality of Send, Flush and Receive, the Do
+// method cannot be called concurrently with the other methods.
 //
 // For full concurrent access to Redis, use the thread-safe Pool to get and
 // release connections from within a goroutine.

+ 10 - 3
redis/scan.go

@@ -186,9 +186,9 @@ func convertAssign(d interface{}, s interface{}) (err error) {
 
 // Scan copies from the multi-bulk src to the values pointed at by dest.
 //
-// The values pointed at by dest 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.
+// The values pointed at by dest must be an integer, float, boolean, string, or
+// []byte. Scan uses the standard strconv package to convert bulk values to
+// numeric and boolean types.
 //
 // If a dest value is nil, then the corresponding src value is skipped.
 //
@@ -323,6 +323,13 @@ func structSpecForType(t reflect.Type) *structSpec {
 //      Field int `redis:"myName"`
 //
 // Fields with the tag redis:"-" are ignored.
+//
+// Integer, float boolean string and []byte fields are supported. Scan uses
+// the standard strconv package to convert bulk values to numeric and boolean
+// types.
+//
+// If the multi-bulk value is nil, then the corresponding field is not
+// modified.
 func ScanStruct(src []interface{}, dest interface{}) error {
 	d := reflect.ValueOf(dest)
 	if d.Kind() != reflect.Ptr || d.IsNil() {