In addition to Joshua's suggestion, I would point to Composition. Something like this:
// Anything with a GetComment implicitly implements this Interface type AsmComment interface { GetComment() string // presuming any line could have a comment } type AsmEntry interface { GetEntry() string // renders the full line as it would be in the file, maybe } type Comment struct { Comment string } func (c *Comment) GetComment() string { return c.Comment; } // Can labels have comments as well? This implementation says no, but it does implement AsmEntry type Label string func (l Label) GetEntry() { return l } type Instruction interface { GetMnemonic() string GetArgsLen() int GetArg(int) string } // By including Comment without a name, it is 'embedded', composed into the IntelInstruction struct, which means that IntelInstruction fulfills the // AsmComment interface automatically type IntelInstruction struct { Comment Mnemonic string Args []string } ...GetMnemonic... ...GetArgsLen... etc // The presence of this function fulfills the AsmEntry interface. func (i IntelInstruction) GetEntry() string { //Do stuff here } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.