| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package interfaces |
| 6 |
|
| 7 |
type I interface { |
| 8 |
Rand() int32 |
| 9 |
} |
| 10 |
|
| 11 |
type SameI interface { |
| 12 |
Rand() int32 |
| 13 |
} |
| 14 |
|
| 15 |
type LargerI interface { |
| 16 |
Rand() int32 |
| 17 |
AnotherFunc() |
| 18 |
} |
| 19 |
|
| 20 |
func Add3(r I) int32 { |
| 21 |
return r.Rand() + r.Rand() + r.Rand() |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
type seven struct{} |
| 27 |
|
| 28 |
func (seven) Rand() int32 { return 7 } |
| 29 |
|
| 30 |
func Seven() I { return seven{} } |
| 31 |
|
| 32 |
type WithParam interface { |
| 33 |
HasParam(p bool) |
| 34 |
} |
| 35 |
|
| 36 |
type Error interface { |
| 37 |
Err() error |
| 38 |
} |
| 39 |
|
| 40 |
func CallErr(e Error) error { |
| 41 |
return e.Err() |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
type I1 interface { |
| 46 |
J() |
| 47 |
H() *seven |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
type I2 interface { |
| 52 |
f() |
| 53 |
G() |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
type I3 interface { |
| 59 |
F() I1 |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
func F() seven { return seven{} } |
| 64 |
func G(u seven) {} |
| 65 |
|
| 66 |
|
| 67 |
type Interfaces interface { |
| 68 |
SomeMethod() |
| 69 |
} |