From a1706cf168f4625ceb53e307d087d41a3d3011c0 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Sat, 2 Aug 2014 01:02:04 +0300 Subject: [PATCH] Remove Implements --- structure.go | 6 ------ structure_example_test.go | 26 -------------------------- structure_test.go | 16 ---------------- 3 files changed, 48 deletions(-) diff --git a/structure.go b/structure.go index 4b3fb39..addd00e 100644 --- a/structure.go +++ b/structure.go @@ -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. diff --git a/structure_example_test.go b/structure_example_test.go index 4fdbcd0..dcb12ea 100644 --- a/structure_example_test.go +++ b/structure_example_test.go @@ -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 -} diff --git a/structure_test.go b/structure_test.go index 5795746..3980960 100644 --- a/structure_test.go +++ b/structure_test.go @@ -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) - -}