gitlab.com/picnic-app/backend/role-api@v0.0.0-20230614140944-06a76ff3696d/internal/util/convert/convert.go (about)

     1  package convert
     2  
     3  import "cloud.google.com/go/spanner"
     4  
     5  func ToPointer[T any](item T) *T {
     6  	return &item
     7  }
     8  
     9  func ToPointers[T any](items []T) []*T {
    10  	var out []*T
    11  	for _, item := range items {
    12  		item := item
    13  		out = append(out, &item)
    14  	}
    15  
    16  	return out
    17  }
    18  
    19  func ToValues[T any](items []*T) []T {
    20  	var out []T
    21  	for _, item := range items {
    22  		out = append(out, *item)
    23  	}
    24  
    25  	return out
    26  }
    27  
    28  func ToNullString(item string) spanner.NullString {
    29  	return spanner.NullString{StringVal: item, Valid: item != ""}
    30  }