github.com/ltltlt/go-source-code@v0.0.0-20190830023027-95be009773aa/cmd/api/testdata/src/pkg/p1/p1.go (about)

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