Skip to content

Instantly share code, notes, and snippets.

@nidhi-canopas
Created February 22, 2022 05:49
Show Gist options
  • Select an option

  • Save nidhi-canopas/46511ce5f74853e70d72b3c956b7b662 to your computer and use it in GitHub Desktop.

Select an option

Save nidhi-canopas/46511ce5f74853e70d72b3c956b7b662 to your computer and use it in GitHub Desktop.
import (
"fmt"
"strings"
"strconv"
)
func main() {
result := ConvertSliceToString([]int{10, 20, 30, 40})
fmt.Println("Slice converted string : ", result)
}
func ConvertSliceToString(input []int) string {
var output []string
for _, i := range input {
output = append(output, strconv.Itoa(i))
}
return strings.Join(output, ",")
}
output:
Slice converted string : 10,20,30,40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment