2012-02-18 14:15:42 -07:00
|
|
|
// run
|
2009-03-20 17:30:54 -06:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2009-05-08 16:21:41 -06:00
|
|
|
import "os"
|
|
|
|
|
2009-03-20 17:30:54 -06:00
|
|
|
type S struct { i int }
|
|
|
|
func (p *S) Get() int { return p.i }
|
|
|
|
|
|
|
|
type Empty interface {
|
|
|
|
}
|
|
|
|
|
|
|
|
type Getter interface {
|
|
|
|
Get() int;
|
|
|
|
}
|
|
|
|
|
|
|
|
func f1(p Empty) {
|
|
|
|
switch x := p.(type) {
|
2011-11-04 10:03:50 -06:00
|
|
|
default: println("failed to match interface", x); os.Exit(1);
|
2009-03-20 17:30:54 -06:00
|
|
|
case Getter: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var s S;
|
|
|
|
f1(&s);
|
|
|
|
}
|