92a219e9c8
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
21 lines
283 B
Go
21 lines
283 B
Go
package iio
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
)
|
|
|
|
func CloseIfCloseable(r interface{}) error {
|
|
log.Println("closing file...")
|
|
if r == nil {
|
|
return nil
|
|
}
|
|
|
|
closer, ok := r.(io.Closer)
|
|
if !ok {
|
|
log.Println("file is not implementing close method")
|
|
return nil
|
|
}
|
|
|
|
return closer.Close()
|
|
}
|