Handle various uint/int types Needed after change to go-ole Value() method.
diff --git a/wmi.go b/wmi.go index 6ea8053..9f2a5be 100644 --- a/wmi.go +++ b/wmi.go
@@ -260,16 +260,8 @@ defer prop.Clear() switch val := prop.Value().(type) { - case int, int64: - var v int64 - switch val := val.(type) { - case int: - v = int64(val) - case int64: - v = val - default: - panic("unexpected type") - } + case int8, int16, int32, int64, int: + v := reflect.ValueOf(val).Int() switch f.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: f.SetInt(v) @@ -282,6 +274,20 @@ Reason: "not an integer class", } } + case uint8, uint16, uint32, uint64: + v := reflect.ValueOf(val).Uint() + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + f.SetInt(int64(v)) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + f.SetUint(v) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not an integer class", + } + } case string: iv, err := strconv.ParseInt(val, 10, 64) switch f.Kind() {