github.com/kdevb0x/go@v0.0.0-20180115030120-39687051e9e7/src/go/doc/testdata/issue18063.go (about) 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 issue18063 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 15 // NewArray is not a factory function because arrays of type T are not 16 // factory functions of type T. 17 func NewArray() [1]T { return [1]T{T{}} } 18 19 // NewPointerArray is not a factory function because arrays of type *T are not 20 // factory functions of type T. 21 func NewPointerArray() [1]*T { return [1]*T{&T{}} } 22 23 // NewSliceOfSlice is not a factory function because slices of a slice of 24 // type *T are not factory functions of type T. 25 func NewSliceOfSlice() [][]T { return []T{[]T{}} } 26 27 // NewPointerSliceOfSlice is not a factory function because slices of a 28 // slice of type *T are not factory functions of type T. 29 func NewPointerSliceOfSlice() [][]*T { return []*T{[]*T{}} } 30 31 // NewSlice3 is not a factory function because 3 nested slices of type T 32 // are not factory functions of type T. 33 func NewSlice3() [][][]T { return []T{[]T{[]T{}}} }