My understanding is that the curly brace following a type is a way to indicate the compiler that you are passing a composite literal. This allow to assign value of different composite type at declaration time.
The same composite literal approach can be used to assign any composite type at declaration time ( array, struct, pointer, function, interface, slice, map, and channel types).
I believe the designer of golang selected that way so it make it very easy to assign anything at declaration time in a consistent way. Actually the only thing that cannot be assigned as a composite literal are value of a predeclared type built in the language itseff (int, string, bool, float, etc ). Composite literal can also be nested allowing to compose complex assignment.
By the way, I am very much new to all that and not authoritative in anyway. Hope it make sense, if not try reading the code explaining it to yourself using the word used on effective go site.
Maybe an example can help me explain better how it help consistency:
package main
import (
"fmt"
)
func main() {
// predeclared type are assigned directly
i := 10
b := true
s := "some string"
// Anything that use a predeclared type to "compose" a type need to use
// a composite literal to assign at declaration time.
// e.g. a value of a type slice of int. Mean a composite formed with the underlying
// type "int" in a slice
xi := []int{42, 43, 44}
// composite literal to assign a value of type []string
xs := []string{"some", "string", "in", "a", "slice"}
// composite literal to assign a value to type map[string]string
m := map[string]string{"some key": "some value"}
// composite literal to assign a value to type map[string][]string
mss := map[string][]string{"some key": []string{"some", "string", "in", "a", "slice"}}
// composite literal to assign an anonymous struct
s2 := struct {
first string
last string
}{
first: "James",
last: "bond"}
// composite literal to assign an anonymous func
f := func() {
fmt.Println("an anonynous func()")
}
// using the value
fmt.Println(i,b,xi, xs, s, m, mss, s2)
f()
}