composite literal

Go syntax that builds a struct, slice or map value in place by listing its contents in braces, such as Target{Name: "api", Port: 8080}.

In more detail

Naming the fields makes construction readable and safe when fields are added later; any field you leave out gets its zero value. Slice and map literals, such as []string{"api", "worker"}, work the same way.

Example

target := Target{Name: "api", Port: 8080}

Related terms

Taught in

References