Debian Codegraph @

src/go/doc/testdata/issue22856.go

raw
1 // Copyright 2017 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 package issue22856
6
7 type T struct{}
8
9 func New() T { return T{} }
10 func NewPointer() *T { return &T{} }
11 func NewPointerSlice() []*T { return []*T{&T{}} }
12 func NewSlice() []T { return []T{T{}} }
13 func NewPointerOfPointer() **T { x := &T{}; return &x }
14 func NewArray() [1]T { return [1]T{T{}} }
15 func NewPointerArray() [1]*T { return [1]*T{&T{}} }
16
17 // NewSliceOfSlice is not a factory function because slices of a slice of
18 // type *T are not factory functions of type T.
19 func NewSliceOfSlice() [][]T { return []T{[]T{}} }
20
21 // NewPointerSliceOfSlice is not a factory function because slices of a
22 // slice of type *T are not factory functions of type T.
23 func NewPointerSliceOfSlice() [][]*T { return []*T{[]*T{}} }
24
25 // NewSlice3 is not a factory function because 3 nested slices of type T
26 // are not factory functions of type T.
27 func NewSlice3() [][][]T { return []T{[]T{[]T{}}} }