jio

package
v5.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: MPL-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecompressAndDeserialize

func DecompressAndDeserialize(data []byte, result any) error

DecompressAndDeserialize decompresses the buffer, then loads JSON data from it.

func Load

func Load(ctx context.Context, r io.Reader, data any) error

Load JSON data.

func LoadFromFS

func LoadFromFS(ctx context.Context, fileSystem fs.FS, path string, data any) error

LoadFromFS loads JSON data from the specified filesystem path.

func LoadFromFile

func LoadFromFile(ctx context.Context, path string, data any) error

LoadFromFile loads JSON data from the specified path.

func Save

func Save(ctx context.Context, w io.Writer, data any) error

Save writes the data as JSON.

func SaveToFile

func SaveToFile(ctx context.Context, path string, data any) error

SaveToFile writes the data as JSON to the given path. Parent directories will be created automatically, if needed.

func SerializeAndCompress

func SerializeAndCompress(data any) ([]byte, error)

SerializeAndCompress writes the data as JSON into a buffer, then compresses it.

Types

type Time

type Time time.Time

Time is a time.Time that has been tailored to be used with JSON in this application.

func NewTimeFrom added in v5.3.0

func NewTimeFrom(s string) (Time, error)

NewTimeFrom returns a time & date from a string.

func Now

func Now() Time

Now returns the current local time.

func (Time) After

func (e Time) After(other Time) bool

After reports whether this time is after the other time.

func (Time) MarshalJSON

func (e Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Time) String

func (e Time) String() string

func (*Time) UnmarshalJSON

func (e *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL