On Sunday, August 21, 2016 at 3:04:02 PM UTC-7, Asit Dhal wrote: > > Hi all, > I use defer to release resource at function level. > > func test() { > a := A.Open() > defer a.Close() > //other code > } > > I need the object a, to be wrapped in a struct. Can someone tell me how to > make a.Close() in this case *elegantly ?* >
Maybe not what you're getting at, but based on your very brief description, why not put a "Close" method on the surrounding struct and defer Close on the containing struct? Eric. > > Warm Regards, > Asit Dhal > http://bit.ly/193ASIT > -- 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.