github.com/sagernet/sing@v0.4.0-beta.19.0.20240518125136-f67a0988a636/common/closer.go (about) 1 package common 2 3 import "io" 4 5 type closeWrapper struct { 6 closer func() error 7 } 8 9 func (w *closeWrapper) Close() error { 10 return w.closer() 11 } 12 13 func Closer(closer func() error) io.Closer { 14 if closer == nil { 15 return nil 16 } 17 return &closeWrapper{closer} 18 }