github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/api/testdata/src/pkg/p1/p1.go (about) 1 // Copyright 2012 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 p1 6 7 import ( 8 ptwo "p2" 9 ) 10 11 const ( 12 ConstChase2 = constChase // forward declaration to unexported ident 13 constChase = AIsLowerA // forward declaration to exported ident 14 15 // Deprecated: use B. 16 A = 1 17 a = 11 18 A64 int64 = 1 19 20 AIsLowerA = a // previously declared 21 ) 22 23 const ( 24 ConversionConst = MyInt(5) 25 ) 26 27 // Variables from function calls. 28 var ( 29 V = ptwo.F() 30 // Deprecated: use WError. 31 VError = BarE() 32 V1 = Bar1(1, 2, 3) 33 V2 = ptwo.G() 34 ) 35 36 // Variables with conversions: 37 var ( 38 StrConv = string("foo") 39 ByteConv = []byte("foo") 40 ) 41 42 var ChecksumError = ptwo.NewError("gzip checksum error") 43 44 const B0 = 2 45 const StrConst = "foo" 46 const FloatConst = 1.5 47 48 type myInt int 49 50 type MyInt int 51 52 type Time struct{} 53 54 type S struct { 55 // Deprecated: use PublicTime. 56 Public *int 57 private *int 58 PublicTime Time 59 } 60 61 // Deprecated: use URI. 62 type URL struct{} 63 64 type EmbedURLPtr struct { 65 *URL 66 } 67 68 type S2 struct { 69 // Deprecated: use T. 70 S 71 Extra bool 72 } 73 74 var X0 int64 75 76 var ( 77 Y int 78 X I 79 ) 80 81 type Namer interface { 82 Name() string 83 } 84 85 type I interface { 86 Namer 87 ptwo.Twoer 88 Set(name string, balance int64) 89 // Deprecated: use GetNamed. 90 Get(string) int64 91 GetNamed(string) (balance int64) 92 private() 93 } 94 95 type Public interface { 96 X() 97 Y() 98 } 99 100 // Deprecated: Use Unexported. 101 type Private interface { 102 X() 103 y() 104 } 105 106 type Error interface { 107 error 108 Temporary() bool 109 } 110 111 func (myInt) privateTypeMethod() {} 112 func (myInt) CapitalMethodUnexportedType() {} 113 114 // Deprecated: use TMethod. 115 func (s *S2) SMethod(x int8, y int16, z int64) {} 116 117 type s struct{} 118 119 func (s) method() 120 func (s) Method() 121 122 func (S) StructValueMethod() 123 func (ignored S) StructValueMethodNamedRecv() 124 125 func (s *S2) unexported(x int8, y int16, z int64) {} 126 127 func Bar(x int8, y int16, z int64) {} 128 func Bar1(x int8, y int16, z int64) uint64 {} 129 func Bar2(x int8, y int16, z int64) (uint8, uint64) {} 130 func BarE() Error {} 131 132 func unexported(x int8, y int16, z int64) {} 133 134 func TakesFunc(f func(dontWantName int) int) 135 136 type Codec struct { 137 Func func(x int, y int) (z int) 138 } 139 140 type SI struct { 141 I int 142 } 143 144 var SIVal = SI{} 145 var SIPtr = &SI{} 146 var SIPtr2 *SI 147 148 type T struct { 149 common 150 } 151 152 type B struct { 153 common 154 } 155 156 type common struct { 157 i int 158 } 159 160 type TPtrUnexported struct { 161 *common 162 } 163 164 type TPtrExported struct { 165 *Embedded 166 } 167 168 type FuncType func(x, y int, s string) (b *B, err error) 169 170 type Embedded struct{} 171 172 func PlainFunc(x, y int, s string) (b *B, err error) 173 174 func (*Embedded) OnEmbedded() {} 175 176 func (*T) JustOnT() {} 177 func (*B) JustOnB() {} 178 func (*common) OnBothTandBPtr() {} 179 func (common) OnBothTandBVal() {} 180 181 type EmbedSelector struct { 182 Time 183 } 184 185 const ( 186 foo = "foo" 187 foo2 string = "foo2" 188 truth = foo == "foo" || foo2 == "foo2" 189 ) 190 191 func ellipsis(...string) {} 192 193 func Now() Time { 194 var now Time 195 return now 196 } 197 198 var x = &S{ 199 Public: nil, 200 private: nil, 201 PublicTime: Now(), 202 } 203 204 var parenExpr = (1 + 5) 205 206 var funcLit = func() {} 207 208 var m map[string]int 209 210 var chanVar chan int 211 212 var ifaceVar any = 5 213 214 var assertVar = ifaceVar.(int) 215 216 var indexVar = m["foo"] 217 218 var Byte byte 219 var ByteFunc func(byte) rune 220 221 type ByteStruct struct { 222 B byte 223 R rune 224 }