sing/common/closer.go
2022-08-17 21:07:38 +08:00

18 lines
254 B
Go

package common
import "io"
type closeWrapper struct {
closer func() error
}
func (w *closeWrapper) Close() error {
return w.closer()
}
func Closer(closer func() error) io.Closer {
if closer == nil {
return nil
}
return &closeWrapper{closer}
}