> Does this not work?
It works
However, this is what I have recently found quite a lot. An interface is defined:
type Foo interface {
Method1()
unexportedMethod()
}
And in the same package, only one type (usually unexported) implements the interface. And the functions declared in the package typically take the concrete type instead of the interface type.This is typical when developers come from Java and they do `abstract class Fooer` and immediately do `class Foo implements Fooer` within the same package. This is an anti pattern in Go.
> This seems like some arbitrary rule that the creators of Go claimed was a good idea, I guess
No. I think I was unclear. I specifically mention that it's not a great idea. It's a code smell. Instead, interfaces should be defined at point-of-use.