migrate go version to 1.17 (#203)

* migrate go version to 1.17

* update contributing
This commit is contained in:
tobi 2021-09-10 14:42:14 +02:00 committed by GitHub
commit f2e5bedea6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
282 changed files with 11863 additions and 12600 deletions

View file

@ -77,6 +77,17 @@ func Scanner(typ reflect.Type) ScannerFunc {
}
}
switch typ {
case timeType:
return scanTime
case ipType:
return scanIP
case ipNetType:
return scanIPNet
case jsonRawMessageType:
return scanBytes
}
if typ.Implements(scannerType) {
return scanScanner
}
@ -88,17 +99,8 @@ func Scanner(typ reflect.Type) ScannerFunc {
}
}
switch typ {
case timeType:
return scanTime
case ipType:
return scanIP
case ipNetType:
return scanIPNet
case bytesType:
if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 {
return scanBytes
case jsonRawMessageType:
return scanJSONRawMessage
}
return scanners[kind]
@ -218,7 +220,10 @@ func scanBytes(dest reflect.Value, src interface{}) error {
dest.SetBytes([]byte(src))
return nil
case []byte:
dest.SetBytes(src)
clone := make([]byte, len(src))
copy(clone, src)
dest.SetBytes(clone)
return nil
}
return fmt.Errorf("bun: can't scan %#v into %s", src, dest.Type())
@ -345,21 +350,6 @@ func scanIPNet(dest reflect.Value, src interface{}) error {
return nil
}
func scanJSONRawMessage(dest reflect.Value, src interface{}) error {
if src == nil {
dest.SetBytes(nil)
return nil
}
b, err := toBytes(src)
if err != nil {
return err
}
dest.SetBytes(b)
return nil
}
func addrScanner(fn ScannerFunc) ScannerFunc {
return func(dest reflect.Value, src interface{}) error {
if !dest.CanAddr() {