1 // Copyright 2026 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // This file contains examples of composite literals.
6 // The examples don't typecheck.
7
8 package p
9
10 var (
11 _ = []int{}
12 _ = [...]int{}
13 _ = [42]int{}
14 _ = map[string]int{}
15 _ = T{}
16 _ = T{1, 2, 3}
17 _ = T{{}, T{}, []int{1, 2, 3}}
18 )
19
20 var (
21 _ []int = {1, 2, 3}
22 _ T = {1: {}, 2: {}}
23 _ = T({"a", "b"})
24 _ = f(x, y, []byte{1, 2, 3})
25 _ = f(x, y, {1, 2, 3})
26 _ = g({foo: x, bar: y})
27 )
28
View as plain text