Rémy Oudompheng | 2ece2f5 | 2012-02-18 22:15:42 +0100 | [diff] [blame] | 1 | // run |
Ian Lance Taylor | 3f69acf | 2008-12-30 15:03:46 -0800 | [diff] [blame] | 2 | |
| 3 | // Copyright 2009 The Go Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
| 7 | package main |
| 8 | |
Russ Cox | 918afd94 | 2009-05-08 15:21:41 -0700 | [diff] [blame] | 9 | import "os" |
| 10 | |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 11 | type I interface { send(chan <- int) } |
Ian Lance Taylor | 3f69acf | 2008-12-30 15:03:46 -0800 | [diff] [blame] | 12 | |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 13 | type S struct { v int } |
Ian Lance Taylor | 3f69acf | 2008-12-30 15:03:46 -0800 | [diff] [blame] | 14 | func (p *S) send(c chan <- int) { c <- p.v } |
| 15 | |
| 16 | func main() { |
Rob Pike | 74dd0ab | 2009-08-17 13:30:22 -0700 | [diff] [blame] | 17 | s := S{0}; |
| 18 | var i I = &s; |
| 19 | c := make(chan int); |
| 20 | go i.send(c); |
| 21 | os.Exit(<-c); |
Ian Lance Taylor | 3f69acf | 2008-12-30 15:03:46 -0800 | [diff] [blame] | 22 | } |