News for hackers. Stuff that matters.
Re:Introduction to Go 1.1 by ansible on Tuesday March 26, 2013 @10:01AM (#5443290)
You'd just want to have your types implement the interface for Reply, and provide a method with the same signature that clients can use.

Here's what I think you want, written in (as far as I am able to) idiomatic Go:

http://play.golang.org/p/KI79ynfRg2

Re:Introduction to Go 1.1 by AndrewDucker on Tuesday March 26, 2013 @11:04AM (#5443746)
So every type that can be returned from a service call has to implement Reply? That's acres of template code being duplicated all over the place - and if I need to fix a defect in it I need to change it in every place!

That strikes me as terribly unmaintainable.

Re:Introduction to Go 1.1 by grey-area on Tuesday March 26, 2013 @12:23PM (#5444316)
So every type that can be returned from a service call has to implement Reply?

Yes, if you want it to actually be a Reply, it has to implement Reply.

That's acres of template code being duplicated all over the place

No, if you need to reuse code you can use other techniques like embedding (not shown in examples).

The features and restrictions differ from many other OO languages but I think the creators of Go deserve a little more credit than you are giving them - they do not produce unmaintainable code (see std lib for Go), worked on a large scale with C++ OOP previously, designed the forking Unix operating system, and are not unaware of the ramifications of the decisions taken.

Re:Introduction to Go 1.1 by ansible on Tuesday March 26, 2013 @12:27PM (#5444349)
Well, you can implement methods based on the Reply interface instead. As long as there are common fields or methods that all the types have, you can have a single CheckStatus() that uses those.

Maybe I don't know what exactly you want.

The Foo and Bar in my example have quite different CheckStatus() methods because those two structs are quite different. If there were more similar, then you could share more code.

Re:Introduction to Go 1.1 by quatrevingts on Tuesday March 26, 2013 @11:02AM (#5443730)
This means that your objects are aware of every "container" that might hold them. This does not scale, and it certainly doesn't work for reusing data structures.
Re:Introduction to Go 1.1 by Evbn on Tuesday March 26, 2013 @06:23PM (#5446455)
It scales in the sense that all types are extensible: you can make A implement B by adding the appropriate definitions anywhere, not just in the file that defines B. Rubyists call this monkey patching and they love it (but Ruby monkey patching can do wackier things beyond adding new methods)
Re:Introduction to Go 1.1 by quatrevingts on Tuesday March 26, 2013 @10:43PM (#5447469)
But I can only make A implement B in the file that defines A, at least according to the comments here:

https://news.ycombinator.com/item?id=5443344