1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-02-01 13:07:51 +02:00

Fix unnecessary type assertion in switch clause (#167)

This commit is contained in:
Yoshi Yamaguchi 2019-10-04 16:17:11 +09:00 committed by rghetia
parent cd5ee69468
commit b5c984b839

View File

@ -403,29 +403,29 @@ func otTagsToOtelAttributesKindAndError(tags map[string]interface{}) ([]otelcore
func otTagToOtelCoreKeyValue(k string, v interface{}) otelcore.KeyValue {
key := otTagToOtelCoreKey(k)
switch v.(type) {
switch val := v.(type) {
case bool:
return key.Bool(v.(bool))
return key.Bool(val)
case int64:
return key.Int64(v.(int64))
return key.Int64(val)
case uint64:
return key.Uint64(v.(uint64))
return key.Uint64(val)
case float64:
return key.Float64(v.(float64))
return key.Float64(val)
case int32:
return key.Int32(v.(int32))
return key.Int32(val)
case uint32:
return key.Uint32(v.(uint32))
return key.Uint32(val)
case float32:
return key.Float32(v.(float32))
return key.Float32(val)
case int:
return key.Int(v.(int))
return key.Int(val)
case uint:
return key.Uint(v.(uint))
return key.Uint(val)
case string:
return key.String(v.(string))
return key.String(val)
case []byte:
return key.Bytes(v.([]byte))
return key.Bytes(val)
default:
return key.String(fmt.Sprint(v))
}