github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/otto/closer.go (about) 1 package otto 2 3 import ( 4 "io" 5 ) 6 7 // maybeClose is a function that can easily be deferred or called at any 8 // point and will close the given value if it is an io.Closer. 9 func maybeClose(v interface{}) error { 10 if c, ok := v.(io.Closer); ok { 11 return c.Close() 12 } 13 14 return nil 15 }