To declare a string array in Go, you can use array literal syntax or the make() function to create an array with string elements.
In this example,
stringArray
using array literal syntax with predefined string values.package main
import "fmt"
func main() {
stringArray := []string{"Hello", "World", "Go"}
fmt.Println("String Array:", stringArray)
}
String Array: [Hello World Go]
In this example,
emptyStringArray
using the make() function with length 0.package main
import "fmt"
func main() {
emptyStringArray := make([]string, 0)
fmt.Println("Empty String Array:", emptyStringArray)
}
Empty String Array: []
In this tutorial, we learned How to Declare a String Array in Go language with well detailed examples.