github.com/c-darwin/mobile@v0.0.0-20160313183840-ff625c46f7c9/bind/testdata/interfaces.go (about)

     1  // Copyright 2014 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 interfaces
     6  
     7  type I interface {
     8  	Rand() int32
     9  }
    10  
    11  func Add3(r I) int32 {
    12  	return r.Rand() + r.Rand() + r.Rand()
    13  }
    14  
    15  // chosen by fair dice roll.
    16  // guaranteed to be random.
    17  type seven struct{}
    18  
    19  func (seven) Rand() int32 { return 7 }
    20  
    21  func Seven() I { return seven{} }
    22  
    23  type WithParam interface {
    24  	HasParam(p bool)
    25  }
    26  
    27  type Error interface {
    28  	Err() error
    29  }
    30  
    31  func CallErr(e Error) error {
    32  	return e.Err()
    33  }
    34  
    35  // not implementable
    36  type I1 interface {
    37  	J()
    38  	H() *seven // not bound
    39  }
    40  
    41  // not implementable
    42  type I2 interface {
    43  	f()
    44  	G()
    45  }
    46  
    47  // implementable
    48  // (the implementor has to find a source of I1s)
    49  type I3 interface {
    50  	F() I1
    51  }
    52  
    53  // not bound
    54  func F() seven  { return seven{} }
    55  func G(u seven) {}