goseth

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 5 Imported by: 7

README

seth

Seth is a Go library that is used for serializing everything from a single root.

Documentation

Overview

Package goseth defines a serializer for Go data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Serializer

type Serializer interface {
	// SetRoot sets the item to be serialized.
	SetRoot(item any)

	// SetMaxDepth sets the maximum depth of the serialization. If the depth
	// is exceeded, the serializer will stop serializing the item.
	// SetMaxDepth(-1) means no limit.
	SetMaxDepth(depth int)

	// SetEntryPoint sets the entry point of the serialization. If this
	// function is not called, the entry point is the root item. Otherwise, the
	// serializer will first drill down to the specific point before
	// serializing. For example, suppose we have a struct called Foo that has a
	// field called Bar. If we set the root to be Foo and set the entry point to
	// be []string{"Bar"}, the serializer will only serialize the Bar field.
	SetEntryPoint(entryPoint []string) error

	// Serialize serializes the item into the writer.
	Serialize(writer io.Writer) error
}

Serializer can serialize anything into a json format.

func NewSerializer added in v0.1.0

func NewSerializer() Serializer

NewSerializer returns a new default serializer.

Jump to

Keyboard shortcuts

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