format

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DataFormatHelpMap = HelpMap{
		string(FORMAT_LIST): "List format",
		string(FORMAT_JSON): "JSON format",
		string(FORMAT_YAML): "YAML format",
	}
)

Functions

func MarshalData

func MarshalData(data any, outFormat DataFormat) ([]byte, error)

MarshalData marshals arbitrary data into a byte slice formatted as outFormat. If a marshalling error occurs or outFormat is unknown, an error is returned.

Supported values are: json, list, yaml

func UnmarshalData

func UnmarshalData(data []byte, v any, inFormat DataFormat) error

UnmarshalData unmarshals a byte slice formatted as inFormat into an interface v. If an unmarshalling error occurs or inFormat is unknown, an error is returned.

Supported values are: json, list, yaml

Types

type DataFormat

type DataFormat string
const (
	FORMAT_LIST DataFormat = "list"
	FORMAT_JSON DataFormat = "json"
	FORMAT_YAML DataFormat = "yaml"
)

func DataFormatFromFileExt

func DataFormatFromFileExt(path string, defaultFmt DataFormat) DataFormat

func (*DataFormat) Set

func (df *DataFormat) Set(v string) error

func (DataFormat) String

func (df DataFormat) String() string

func (DataFormat) Type

func (df DataFormat) Type() string

type HelpMap

type HelpMap map[string]string

Jump to

Keyboard shortcuts

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