Documentation ¶
Overview ¶
Package iox provides boilerplate wrapper functions for the Go standard io functions to Read, Open, Write, and Save, with implementations for commonly used encoding formats.
Index ¶
- func Open(v any, filename string, f DecoderFunc) error
- func OpenFS(v any, fsys fs.FS, filename string, f DecoderFunc) error
- func OpenFiles(v any, filenames []string, f DecoderFunc) error
- func OpenFilesFS(v any, fsys fs.FS, filenames []string, f DecoderFunc) error
- func Read(v any, reader io.Reader, f DecoderFunc) error
- func ReadBytes(v any, data []byte, f DecoderFunc) error
- func Save(v any, filename string, f EncoderFunc) error
- func Write(v any, writer io.Writer, f EncoderFunc) error
- func WriteBytes(v any, f EncoderFunc) ([]byte, error)
- type Decoder
- type DecoderFunc
- type Encoder
- type EncoderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
func Open(v any, filename string, f DecoderFunc) error
Open reads the given object from the given filename using the given DecoderFunc
func OpenFS ¶
OpenFS reads the given object from the given filename using the given DecoderFunc, using the given fs.FS filesystem (e.g., for embed files)
func OpenFiles ¶
func OpenFiles(v any, filenames []string, f DecoderFunc) error
OpenFiles reads the given object from the given filenames using the given DecoderFunc
func OpenFilesFS ¶
OpenFilesFS reads the given object from the given filenames using the given DecoderFunc, using the given fs.FS filesystem (e.g., for embed files)
func Read ¶
func Read(v any, reader io.Reader, f DecoderFunc) error
Read reads the given object from the given reader, using the given DecoderFunc
func ReadBytes ¶
func ReadBytes(v any, data []byte, f DecoderFunc) error
ReadBytes reads the given object from the given bytes, using the given DecoderFunc
func Save ¶
func Save(v any, filename string, f EncoderFunc) error
Save writes the given object to the given filename using the given EncoderFunc
func Write ¶
func Write(v any, writer io.Writer, f EncoderFunc) error
Write writes the given object using the given EncoderFunc
func WriteBytes ¶
func WriteBytes(v any, f EncoderFunc) ([]byte, error)
WriteBytes writes the given object, returning bytes of the encoding, using the given EncoderFunc
Types ¶
type Decoder ¶
type Decoder interface { // Decode decodes from io.Reader specified at creation Decode(v any) error }
Decoder is an interface for standard decoder types
type DecoderFunc ¶
DecoderFunc is a function that creates a new Decoder for given reader
func NewDecoderFunc ¶
func NewDecoderFunc[T Decoder](f func(r io.Reader) T) DecoderFunc
NewDecoderFunc returns a DecoderFunc for a specific Decoder type
type EncoderFunc ¶
EncoderFunc is a function that creates a new Encoder for given writer
func NewEncoderFunc ¶
func NewEncoderFunc[T Encoder](f func(w io.Writer) T) EncoderFunc
NewEncoderFunc returns a EncoderFunc for a specific Encoder type