Go Package io

From NovaOrdis Knowledge Base
Revision as of 00:07, 19 December 2023 by Ovidiu (talk | contribs) (→‎Reader)
Jump to navigation Jump to search

External

Internal

Overview

The io package consists of a few functions, but mostly interfaces used by other packages.

Reader

https://golang.org/pkg/io/#Reader

An interface that exposes Read().

Readers can be used to unmarshall JSON into structs as shown here:

Unmarshalling JSON from a Reader into a struct

Files opened with os.Create() implement io.Reader.

Writer

https://golang.org/pkg/io/#Writer

Closer

https://golang.org/pkg/io/#Closer

ReadCloser

An interface that exposes basic Read() and Close() methods. The http.Request body is a ReadCloser. See Reader.