Serveral ways to get io.Reader or io.Writer


1. strings.Reader 

   func NewReader(s string) *Reader

2. bytes.Buffer implements io.Reader, io.Writer interface.

    func NewBuffer(buf []byte) *Buffer

    func NewBufferString(s string) *Buffer

 3. bytes.Reader

   func NewReader(b []byte) *Reader

4. bufio.Reader, bufio.Writer, bufio.ReadWriter

   func NewReader(rd io.Reader) *Reader

   func NewReaderSize(rd io.Reader, size int) *Reader

   func NewWriter(w io.Writer) *Writer

   func NewWriterSize(w io.Writer, size int) *Writer

  func NewReadWriter(r *Reader, w *Writer) *ReadWriter

5. os.File is a io.Reader, io.Writer and io.Closer

   func Create(name string) (*File, error)

    func NewFile(fd uintptr, name string) *File

    func Open(name string) (*File, error)

    func OpenFile(name string, flag int, perm FileMode) (*File, error)




  


Comments:

Write a comment
Anonymous

Captcha image

Reload

Type the number you see in the image above: