How to convert simple code array to string
a := []int{1,2,3}
ayam := "bebek" + a
fmt.Print(ayam)
example
[1,2,3] => "[1,2,3]"
a (mismatched types string and []int)
How to convert simple code array to string
a := []int{1,2,3}
ayam := "bebek" + a
fmt.Print(ayam)
example
[1,2,3] => "[1,2,3]"
a (mismatched types string and []int)
Your best bet would be to use json.Marshal()
.
a := []int{1,2,3}
s, _ := json.Marshal(a)
// s should be "[1, 2, 3]"