Answers for "how to make string array golang"

Go
0

array of string golang

var x [2]string 		// An array of 2 strings
x[1] = "German"
var y [2]string{"English", "Japanese"}

import "fmt"
for i := 0; i < len(y); i++ {
  fmt.Println(y[i])
}
Posted by: Guest on May-05-2021
-1

string array to string golang

str1 := []string{"the","cat","in","the","hat"}
fmt.Println(str1)
 
str2 := strings.Join(str1, " ")
fmt.Println(str2)
 
str3 := strings.Join(str1, ", ")
fmt.Println(str3)
 
Output:
[the cat in the hat]
the cat in the hat
the, cat, in, the, hat
Posted by: Guest on November-05-2021

Browse Popular Code Answers by Language