github.com/tobgu/qframe@v0.4.0/aggregation/strings.go (about)

     1  package aggregation
     2  
     3  import "strings"
     4  
     5  // StrJoin creates a function that joins a slice of strings into
     6  // a single string using the provided separator.
     7  // It is provided as an example and can be used in aggregations
     8  // on string and enum columns.
     9  func StrJoin(sep string) func([]*string) *string {
    10  	return func(input []*string) *string {
    11  		s := make([]string, 0, len(input))
    12  		for _, sPtr := range input {
    13  			if sPtr != nil {
    14  				s = append(s, *sPtr)
    15  			}
    16  		}
    17  
    18  		result := strings.Join(s, sep)
    19  		return &result
    20  	}
    21  }