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