Users want a proper way to implement a Cloneable interface in Go without causing circular dependencies. They are looking for a solution that adheres to Go's strict typing while allowing for effective cloning of objects.
I have a case where I want to create an interface like this: type MyInterface interface { DoSth1(...) ... DoSth2(...) ... DoSth3(...) ... Clone() MyInterface } Clone should create a copy of an object with a copy of it's internal state, that can be modified without changing the original. I need kind of *Prototype* pattern implementation. I have a problem though, what's the correct way to do this, because Go says it should be defined in the package, where it's used. The problem with this approach is, that any package that provides an implementation has a dependency on this package due to return type of the *Clone()* function. This leads easily to circular dependencies. So far I figured I can: 1..Move the definition to package that implements it It seems like good idea in any other language, but I worry in Go it's more of sidestepping the issue. It's also against the idea that implementation and interface definition are completely separate in Go. 2. I can make Clone return *interface{}* type. This feels wrong though, because whole thing with Go being strictly typed language goes away. So I'd like to ask more experienced people, what's the proper "Go" way to do that?