equal
deleted
inserted
replaced
1111 val := reflect.ValueOf(tval) |
1111 val := reflect.ValueOf(tval) |
1112 if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Float64 { |
1112 if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Float64 { |
1113 return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) |
1113 return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) |
1114 } |
1114 } |
1115 |
1115 |
1116 if val.Convert(reflect.TypeOf(int(1))).Int() < 0 { |
1116 if val.Type().Kind() != reflect.Uint64 && val.Convert(reflect.TypeOf(int(1))).Int() < 0 { |
1117 return reflect.ValueOf(nil), fmt.Errorf("%v(%T) is negative so does not fit in %v", tval, tval, mtype.String()) |
1117 return reflect.ValueOf(nil), fmt.Errorf("%v(%T) is negative so does not fit in %v", tval, tval, mtype.String()) |
1118 } |
1118 } |
1119 if reflect.Indirect(reflect.New(mtype)).OverflowUint(val.Convert(reflect.TypeOf(uint64(0))).Uint()) { |
1119 if reflect.Indirect(reflect.New(mtype)).OverflowUint(val.Convert(reflect.TypeOf(uint64(0))).Uint()) { |
1120 return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) |
1120 return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) |
1121 } |
1121 } |