gitlab.com/evatix-go/core@v1.3.55/internal/csvinternal/RangeNamesWithValuesIndexes.go (about)

     1  package csvinternal
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"gitlab.com/evatix-go/core/constants"
     7  )
     8  
     9  // RangeNamesWithValuesIndexes
    10  //
    11  //  Returns a new slice where
    12  //  format
    13  //   - `name[ValueIndex]`
    14  //  example
    15  //   - `SomeName[1]`
    16  func RangeNamesWithValuesIndexes(
    17  	rangedItems ...string,
    18  ) []string {
    19  	if len(rangedItems) == 0 {
    20  		return []string{}
    21  	}
    22  
    23  	compiledRanges := make([]string, len(rangedItems))
    24  
    25  	for i, item := range rangedItems {
    26  		compiledRanges[i] = fmt.Sprintf(
    27  			constants.EnumNameValueFormat,
    28  			item,
    29  			i)
    30  	}
    31  
    32  	return compiledRanges
    33  }