I implemented a type registry solution for this situation: https://github.com/rcoreilly/goki/tree/master/ki/kit
you just add a one-liner after every struct you want to register, and it builds the map for you — makes it fully modular, etc. Cheers, - Randy > On Mar 28, 2018, at 12:59 PM, Alex Efros <[email protected]> wrote: > > Hi! > > On Wed, Mar 28, 2018 at 02:13:55PM -0400, Shawn Milochik wrote: >> Thanks for the challenge! I found some unused code in the getItem function, >> and a way to make it a bit shorter by removing the lookup map. However, >> depending on the number of struct types the map may be cleaner for OP. >> >> https://play.golang.org/p/ZH09nHsrRoR > > This wasn't supposed to be a challenge - I tried to be as less invasive > as possible, just cleanup things a bit. If you wanna challenge - it's here: > https://play.golang.org/p/N8YLUGdP4Kb > I don't bother is it shorter, but (at least to me) it's more clear. > > -- > WBR, Alex. > > -- > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
