gitlab.com/evatix-go/core@v1.3.55/simplewrap/CsvWrapElements.go (about) 1 package simplewrap 2 3 // DoubleQuoteWrapElements Returns new empty slice if nil or empty slice given. 4 // 5 // Reference : https://play.golang.org/p/s_uN2-ckk2F | https://stackoverflow.com/a/48832120 6 func DoubleQuoteWrapElements( 7 isSkipQuoteOnlyOnExistence bool, 8 inputElements ...string, 9 ) (doubleQuoteWrappedItems []string) { 10 if inputElements == nil { 11 return []string{} 12 } 13 14 length := len(inputElements) 15 newSlice := make([]string, length) 16 17 if length == 0 { 18 return newSlice 19 } 20 21 if isSkipQuoteOnlyOnExistence { 22 return wrapDoubleQuoteByExistenceCheck(inputElements, newSlice) 23 } 24 25 for i, item := range inputElements { 26 newSlice[i] = WithDoubleQuote(item) 27 } 28 29 return newSlice 30 }