我怎样才能初始化像这样的指针切片?

I was surprised I could initialize a slice of pointers in this way:

package main

import (
    "fmt"
)

type index struct {
    i, j int
}

func main() {
    indices := []*index{{0, 1}, {1, 3}} // Why does this work?

    fmt.Println(*indices[1])
}

I was expecting to have to write something more verbose like:

indices := []*index{&index{0, 1}, &index{1, 3}}

Where would I find this in the documentation?

From the spec:

Within a composite literal of array, slice, or map type T, elements or map keys that are themselves composite literals may elide the respective literal type if it is identical to the element or key type of T. Similarly, elements or keys that are addresses of composite literals may elide the &T when the element or key type is *T.

Basically, it already knows each element will be a *index, so it saves you having to actually type &index over and over again.

If the slice type is not the same as the element type (perhaps it is a slice of an interface type), you would have to specify the type of each element like so:

indices := []interface{}{&index{0, 1}, &index{1, 3}}