// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* Package attribute provide several helper functions for some commonly used logic of processing attributes. */
package attribute // import "go.opentelemetry.io/otel/internal/attribute" import ( ) // BoolSliceValue converts a bool slice into an array with same elements as slice. func ( []bool) interface{} { var bool := reflect.New(reflect.ArrayOf(len(), reflect.TypeOf())) copy(.Elem().Slice(0, len()).Interface().([]bool), ) return .Elem().Interface() } // Int64SliceValue converts an int64 slice into an array with same elements as slice. func ( []int64) interface{} { var int64 := reflect.New(reflect.ArrayOf(len(), reflect.TypeOf())) copy(.Elem().Slice(0, len()).Interface().([]int64), ) return .Elem().Interface() } // Float64SliceValue converts a float64 slice into an array with same elements as slice. func ( []float64) interface{} { var float64 := reflect.New(reflect.ArrayOf(len(), reflect.TypeOf())) copy(.Elem().Slice(0, len()).Interface().([]float64), ) return .Elem().Interface() } // StringSliceValue converts a string slice into an array with same elements as slice. func ( []string) interface{} { var string := reflect.New(reflect.ArrayOf(len(), reflect.TypeOf())) copy(.Elem().Slice(0, len()).Interface().([]string), ) return .Elem().Interface() } // AsBoolSlice converts a bool array into a slice into with same elements as array. func ( interface{}) []bool { := reflect.ValueOf() if .Type().Kind() != reflect.Array { return nil } var bool := .Len() := reflect.ArrayOf(, reflect.TypeOf()) := reflect.New() _ = reflect.Copy(.Elem(), ) return .Elem().Slice(0, ).Interface().([]bool) } // AsInt64Slice converts an int64 array into a slice into with same elements as array. func ( interface{}) []int64 { := reflect.ValueOf() if .Type().Kind() != reflect.Array { return nil } var int64 := .Len() := reflect.ArrayOf(, reflect.TypeOf()) := reflect.New() _ = reflect.Copy(.Elem(), ) return .Elem().Slice(0, ).Interface().([]int64) } // AsFloat64Slice converts a float64 array into a slice into with same elements as array. func ( interface{}) []float64 { := reflect.ValueOf() if .Type().Kind() != reflect.Array { return nil } var float64 := .Len() := reflect.ArrayOf(, reflect.TypeOf()) := reflect.New() _ = reflect.Copy(.Elem(), ) return .Elem().Slice(0, ).Interface().([]float64) } // AsStringSlice converts a string array into a slice into with same elements as array. func ( interface{}) []string { := reflect.ValueOf() if .Type().Kind() != reflect.Array { return nil } var string := .Len() := reflect.ArrayOf(, reflect.TypeOf()) := reflect.New() _ = reflect.Copy(.Elem(), ) return .Elem().Slice(0, ).Interface().([]string) }