github.com/resonatecoop/user-api@v1.0.0-13.0.20220915120639-05dc9c04014a/internal/pkg/maps/listvalue.go (about)

     1  package maps
     2  
     3  import (
     4  	structpb "github.com/golang/protobuf/ptypes/struct"
     5  )
     6  
     7  // GetMapListValue converts a map of []string to protobuf type *structpb.ListValue
     8  func GetMapListValue(m map[string][]string) map[string]*structpb.ListValue {
     9  	mapListValue := make(map[string]*structpb.ListValue)
    10  	for k, v := range m {
    11  		mapListValue[k] = getListValue(v)
    12  	}
    13  	return mapListValue
    14  }
    15  
    16  func getListValue(strArr []string) *structpb.ListValue {
    17  	values := make([]*structpb.Value, len(strArr))
    18  	for i, v := range strArr {
    19  		values[i] = &structpb.Value{Kind: &structpb.Value_StringValue{v}}
    20  	}
    21  	return &structpb.ListValue{
    22  		Values: values,
    23  	}
    24  }