Source File
value.go
Belonging Package
go.opentelemetry.io/otel/label
package label
import (
)
array interface{}
}
const (
INVALID Type = iota // No value.
BOOL // Boolean value, use AsBool() to get it.
INT32 // 32 bit signed integral value, use AsInt32() to get it.
INT64 // 64 bit signed integral value, use AsInt64() to get it.
UINT32 // 32 bit unsigned integral value, use AsUint32() to get it.
UINT64 // 64 bit unsigned integral value, use AsUint64() to get it.
FLOAT32 // 32 bit floating point value, use AsFloat32() to get it.
FLOAT64 // 64 bit floating point value, use AsFloat64() to get it.
STRING // String value, use AsString() to get it.
ARRAY // Array value of arbitrary type, use AsArray() to get it.
)
func ( int) Value {
if unsafe.Sizeof() == 4 {
return Int32Value(int32())
}
return Int64Value(int64())
}
func ( uint) Value {
if unsafe.Sizeof() == 4 {
return Uint32Value(uint32())
}
return Uint64Value(uint64())
}
func ( Value) () int32 {
return internal.RawToInt32(.numeric)
}
func ( Value) () int64 {
return internal.RawToInt64(.numeric)
}
func ( Value) () uint32 {
return internal.RawToUint32(.numeric)
}
func ( Value) () uint64 {
return internal.RawToUint64(.numeric)
}
func ( Value) () float32 {
return internal.RawToFloat32(.numeric)
}
func ( Value) () float64 {
return internal.RawToFloat64(.numeric)
}
func ( Value) () interface{} {
return .array
}
type unknownValueType struct{}
func ( Value) () interface{} {
switch .Type() {
case ARRAY:
return .AsArray()
case BOOL:
return .AsBool()
case INT32:
return .AsInt32()
case INT64:
return .AsInt64()
case UINT32:
return .AsUint32()
case UINT64:
return .AsUint64()
case FLOAT32:
return .AsFloat32()
case FLOAT64:
return .AsFloat64()
case STRING:
return .stringly
}
return unknownValueType{}
}
func ( Value) () string {
switch .Type() {
case ARRAY:
return fmt.Sprint(.array)
case BOOL:
return strconv.FormatBool(.AsBool())
case INT32:
return strconv.FormatInt(int64(.AsInt32()), 10)
case INT64:
return strconv.FormatInt(.AsInt64(), 10)
case UINT32:
return strconv.FormatUint(uint64(.AsUint32()), 10)
case UINT64:
return strconv.FormatUint(.AsUint64(), 10)
case FLOAT32:
return fmt.Sprint(.AsFloat32())
case FLOAT64:
return fmt.Sprint(.AsFloat64())
case STRING:
return .stringly
default:
return "unknown"
}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |