Skip to content

proposal: io: add CloserFunc and WriterAndCloser  #56373

@mei-rune

Description

@mei-rune

can add CloserFunc and WriterAndCloser

CloserFunc is:

   type CloserFunc  func() error
   
   func (fn CloserFunc) Close() error {
      return fn()
   }

 var _ io.Closer = CloserFunc(func() error {})

WriterAndCloser is:

type writeCloser struct {
	io.Writer
	io.Closer	
}

func WriterAndCloser(w io.Writer, c io.Closer) io.WriteCloser {
	return writeCloser{
		Writer: w,
		Closer: c,
	}
}

see: https://github.com/search?q=CloserFunc+language%3Ago&type=code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions