jio

package
v5.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MPL-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// CurrentDataVersion holds the current version for data files written with the current release. Note that this is
	// intentionally the same for all data files that GCS processes.
	CurrentDataVersion = 5
	// FirstGoDataVersion is the version that was written by the first Go version of GCS.
	FirstGoDataVersion = 4
	// MinimumDataVersion holds the oldest version for data files that can be loaded. Note that this is intentionally
	// the same for all data files that GCS processes.
	MinimumDataVersion    = 2
	MinimumLibraryVersion = 3 // Note that as of the Go version of GCS, the data and library version are the same.
)

These version numbers are used both as the version of the data files written to disk as well as the major version number for GCS library compatibility checking. The Go release of GCS is the first release to synchronize the data version and the library major version.

Variables

This section is empty.

Functions

func CheckVersion added in v5.24.0

func CheckVersion(version int) error

CheckVersion returns an error if the data version is out of the acceptable range.

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) Compare added in v5.19.0

func (e Time) Compare(other Time) int

Compare returns an integer comparing this time to 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