[go-nuts] defer at struct level

2016-08-21 Thread 'Kevin Malachowski' via golang-nuts
Do you have a code sample? I don't quite understand what you mean by something being "wrapped" in a struct. Will 'a' be a field in a struct? If so, you can just access it: defer myStructValue.a.Close() -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] defer at struct level

2016-08-21 Thread asit dhal
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 ? Warm Regards, Asit Dhal http://bit.ly/193ASIT -- You