gitlab.com/evatix-go/core@v1.3.55/coreimpl/enumimpl/KeyAnyValues.go (about)

     1  package enumimpl
     2  
     3  import "reflect"
     4  
     5  func KeyAnyValues(names []string, values interface{}) []KeyAnyVal {
     6  	if len(names) == 0 {
     7  		return []KeyAnyVal{}
     8  	}
     9  
    10  	slice := make([]KeyAnyVal, len(names))
    11  	reflectValues := reflect.ValueOf(values)
    12  	for i, name := range names {
    13  		rfVal := reflectValues.Index(i)
    14  		anyVal := rfVal.Interface()
    15  		slice[i] = KeyAnyVal{
    16  			Key:      name,
    17  			AnyValue: anyVal,
    18  		}
    19  	}
    20  
    21  	return slice
    22  }