Remove Implements

This commit is contained in:
Fatih Arslan 2014-08-02 01:02:04 +03:00
parent 816e3846a4
commit a1706cf168
3 changed files with 0 additions and 48 deletions

View File

@ -194,12 +194,6 @@ func Has(s interface{}, fieldName string) bool {
return false
}
// Implements returns true if the given struct s implements the i interface
// type.
func Implements(s, i interface{}) bool {
return reflect.TypeOf(s).Implements(reflect.TypeOf(i).Elem())
}
// strctInfo returns the struct value and the exported struct fields for a
// given s struct. This is a convenient helper method to avoid duplicate code
// in some of the functions.

View File

@ -2,7 +2,6 @@ package structure
import (
"fmt"
"io"
"time"
)
@ -147,28 +146,3 @@ func ExampleHas() {
// Output:
// Has: true
}
type Bar struct{}
func (b Bar) String() string { return "bar" }
func (b Bar) Write(p []byte) (n int, err error) { return 0, nil }
func ExampleImplements() {
// type Bar struct{}
//
// func (b Bar) String() string { return "bar" }
// func (b Bar) Write(p []byte) (n int, err error) { return 0, nil }
b := Bar{}
okA := Implements(b, new(fmt.Stringer))
okB := Implements(b, new(io.Writer))
okC := Implements(b, new(io.Reader))
fmt.Printf("Implements io.Writer: %+v\n", okA)
fmt.Printf("Implements io.Reader: %+v\n", okB)
fmt.Printf("Implements fmt.Stringer: %+v\n", okC)
// Output:
// Implements io.Writer: true
// Implements io.Reader: true
// Implements fmt.Stringer: false
}

View File

@ -1,8 +1,6 @@
package structure
import (
"fmt"
"io"
"reflect"
"testing"
)
@ -473,17 +471,3 @@ func TestName(t *testing.T) {
t.Error("Name should return empty string for unnamed struct, got: %s", n)
}
}
type Foo struct{}
func (f Foo) String() string { return "foo" }
func (f Foo) Write(p []byte) (n int, err error) { return 0, nil }
func TestImplements(t *testing.T) {
f := Foo{}
ok := Implements(f, new(io.Reader))
fmt.Printf("ok %+v\n", ok)
}