gitlab.com/evatix-go/core@v1.3.55/corecsv/AnyItemsToCsvString.go (about)

     1  package corecsv
     2  
     3  import (
     4  	"strings"
     5  
     6  	"gitlab.com/evatix-go/core/constants"
     7  )
     8  
     9  // AnyItemsToCsvString
    10  //
    11  // if references empty or len 0 then empty string returned.
    12  //
    13  // Final join whole lines with the joiner given (... joiner item)
    14  //
    15  // Formats :
    16  //  - isIncludeQuote && isIncludeSingleQuote = '%v' will be added
    17  //  - isIncludeQuote && !isIncludeSingleQuote = "'%v'" will be added
    18  //  - !isIncludeQuote && !isIncludeSingleQuote = %v will be added
    19  func AnyItemsToCsvString(
    20  	joiner string,
    21  	isIncludeQuote,
    22  	isIncludeSingleQuote bool, // disable this will give double quote
    23  	references ...interface{},
    24  ) string {
    25  	if len(references) == 0 {
    26  		return constants.EmptyString
    27  	}
    28  
    29  	slice := AnyItemsToCsvStrings(
    30  		isIncludeQuote,
    31  		isIncludeSingleQuote,
    32  		references...)
    33  
    34  	return strings.Join(
    35  		slice,
    36  		joiner)
    37  }