Bladeren bron

Improve documentation and tests for redis.Scan()

Gary Burd 12 jaren geleden
bovenliggende
commit
a59211c483
2 gewijzigde bestanden met toevoegingen van 6 en 3 verwijderingen
  1. 3 3
      redis/scan.go
  2. 3 0
      redis/scan_test.go

+ 3 - 3
redis/scan.go

@@ -190,9 +190,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 an integer, float, boolean, string, or
-// []byte. 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,
+// []byte, interface{} or slices of these types. 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.
 //

+ 3 - 0
redis/scan_test.go

@@ -48,10 +48,13 @@ var scanConversionTests = []struct {
 	{[]byte("t"), true},
 	{[]byte("hello"), "hello"},
 	{[]byte("world"), []byte("world")},
+	{[]interface{}{[]byte("foo")}, []interface{}{[]byte("foo")}},
 	{[]interface{}{[]byte("foo")}, []string{"foo"}},
+	{[]interface{}{[]byte("hello"), []byte("world")}, []string{"hello", "world"}},
 	{[]interface{}{[]byte("bar")}, [][]byte{[]byte("bar")}},
 	{[]interface{}{[]byte("1")}, []int{1}},
 	{[]interface{}{[]byte("1"), []byte("2")}, []int{1, 2}},
+	{[]interface{}{[]byte("1"), []byte("2")}, []float64{1, 2}},
 	{[]interface{}{[]byte("1")}, []byte{1}},
 	{[]interface{}{[]byte("1")}, []bool{true}},
 }