@icza and @Burak Serdar have mentioned that [d] is an index expression.
Following is just a working example to see the output
package main
import "fmt"
type Direction int
func (d Direction) String() string {
return [...]string{"North", "East", "South", "West"}[d]
}
func main() {
n:=Direction(0) // d=0
fmt.Println(n)
w:=Direction(3) // d=3
fmt.Println(w)
}
Output:
North
West
To be more clear,
return [...]string{"North", "East", "South", "West"}[d]
can be expanded as
func (d Direction) String() string {
var directions = [...]string{"North", "East", "South", "West"}
return directions[d]
}