gitlab.com/evatix-go/core@v1.3.55/internal/csvinternal/StringsToCsvStrings.go (about) 1 package csvinternal 2 3 import ( 4 "fmt" 5 6 "gitlab.com/evatix-go/core/constants" 7 ) 8 9 // StringsToCsvStrings 10 // 11 // Formats : 12 // - isIncludeQuote && isIncludeSingleQuote = '%v' will be added 13 // - isIncludeQuote && !isIncludeSingleQuote = "'%v'" will be added 14 // - !isIncludeQuote && !isIncludeSingleQuote = %v will be added 15 func StringsToCsvStrings( 16 isIncludeQuote, 17 isIncludeSingleQuote bool, 18 references ...string, 19 ) []string { 20 if len(references) == 0 { 21 return []string{} 22 } 23 24 slice := make([]string, len(references)) 25 26 if isIncludeQuote && isIncludeSingleQuote { 27 // single quote 28 for i, currentReference := range references { 29 slice[i] = fmt.Sprintf( 30 constants.ValueWithSingleQuoteFormat, 31 currentReference) 32 } 33 34 return slice 35 } else if isIncludeQuote && !isIncludeSingleQuote { 36 // double quote 37 for i, currentReference := range references { 38 slice[i] = fmt.Sprintf( 39 constants.ValueWithDoubleQuoteFormat, 40 currentReference) 41 } 42 43 return slice 44 } 45 46 // no quote 47 for i, currentReference := range references { 48 slice[i] = fmt.Sprintf( 49 constants.SprintValueFormat, 50 currentReference) 51 } 52 53 return slice 54 }