News for hackers. Stuff that matters.
Re:Go 1.6 is Released by justinsaccount on Wednesday February 17, 2016 @07:15PM (#11122676)
> But you cannot do the reverse: you cannot make a type from a foreign package conform to your interface by adding new methods to it.

I thought you could.

You don't add the methods directly to it, but you can easily embed the foreign type into a new type that confirms to the interface you want.

  type FooWrapper struct {
    Foo
  }

  func (fw FooWrapper) SomeFunc() {
  ...
  }
Re:Go 1.6 is Released by pcwalton on Wednesday February 17, 2016 @07:29PM (#11122749)
That's making a new type, which causes a lot of friction. For example, a []Foo array is not castable to a []FooWrapper array without recreating the entire thing.