golang.org/x/tools/gopls@v0.15.3/internal/analysis/fillstruct/testdata/src/a/a.go (about) 1 // Copyright 2020 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 fillstruct 6 7 import ( 8 data "b" 9 "go/ast" 10 "go/token" 11 "unsafe" 12 ) 13 14 type emptyStruct struct{} 15 16 var _ = emptyStruct{} 17 18 type basicStruct struct { 19 foo int 20 } 21 22 var _ = basicStruct{} // want `basicStruct literal has missing fields` 23 24 type twoArgStruct struct { 25 foo int 26 bar string 27 } 28 29 var _ = twoArgStruct{} // want `twoArgStruct literal has missing fields` 30 31 var _ = twoArgStruct{ // want `twoArgStruct literal has missing fields` 32 bar: "bar", 33 } 34 35 type nestedStruct struct { 36 bar string 37 basic basicStruct 38 } 39 40 var _ = nestedStruct{} // want `nestedStruct literal has missing fields` 41 42 var _ = data.B{} // want `b.B literal has missing fields` 43 44 type typedStruct struct { 45 m map[string]int 46 s []int 47 c chan int 48 c1 <-chan int 49 a [2]string 50 } 51 52 var _ = typedStruct{} // want `typedStruct literal has missing fields` 53 54 type funStruct struct { 55 fn func(i int) int 56 } 57 58 var _ = funStruct{} // want `funStruct literal has missing fields` 59 60 type funStructComplex struct { 61 fn func(i int, s string) (string, int) 62 } 63 64 var _ = funStructComplex{} // want `funStructComplex literal has missing fields` 65 66 type funStructEmpty struct { 67 fn func() 68 } 69 70 var _ = funStructEmpty{} // want `funStructEmpty literal has missing fields` 71 72 type Foo struct { 73 A int 74 } 75 76 type Bar struct { 77 X *Foo 78 Y *Foo 79 } 80 81 var _ = Bar{} // want `Bar literal has missing fields` 82 83 type importedStruct struct { 84 m map[*ast.CompositeLit]ast.Field 85 s []ast.BadExpr 86 a [3]token.Token 87 c chan ast.EmptyStmt 88 fn func(ast_decl ast.DeclStmt) ast.Ellipsis 89 st ast.CompositeLit 90 } 91 92 var _ = importedStruct{} // want `importedStruct literal has missing fields` 93 94 type pointerBuiltinStruct struct { 95 b *bool 96 s *string 97 i *int 98 } 99 100 var _ = pointerBuiltinStruct{} // want `pointerBuiltinStruct literal has missing fields` 101 102 var _ = []ast.BasicLit{ 103 {}, // want `go/ast.BasicLit literal has missing fields` 104 } 105 106 var _ = []ast.BasicLit{{}} // want "go/ast.BasicLit literal has missing fields" 107 108 type unsafeStruct struct { 109 foo unsafe.Pointer 110 } 111 112 var _ = unsafeStruct{} // want `unsafeStruct literal has missing fields`