Skip to content

Commit

Permalink
Tidy up conversion type switch
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Jan 7, 2016
1 parent 49ee94d commit 05b435e
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions storage/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,17 @@ func checkResponseForErrors(response *influxdb.Response) error {

// Some stats have type unsigned integer, but the InfluxDB client accepts only signed integers.
func toSignedIfUnsigned(value interface{}) interface{} {
switch value.(type) {
switch v := value.(type) {
case uint64:
if v, ok := value.(uint64); ok {
return int64(v)
}
return int64(v)
case uint32:
if v, ok := value.(uint32); ok {
return int32(v)
}
return int32(v)
case uint16:
if v, ok := value.(uint16); ok {
return int16(v)
}
return int16(v)
case uint8:
if v, ok := value.(uint8); ok {
return int8(v)
}
return int8(v)
case uint:
if v, ok := value.(uint); ok {
return int(v)
}
return int(v)
}
return value
}

0 comments on commit 05b435e

Please sign in to comment.