prettygo

package module
v0.0.0-...-0b770bc Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 10 Imported by: 0

README

pretty-go

Pretty Encoder/Decoder/Printer for Go values, Support Multiple Formats (JSON/YAML/More).

Documentation

Index

Constants

View Source
const (
	JSON    = "json"
	TOML    = "toml"
	YAML    = "yaml"
	MSGPACK = "msgpack"
)

Variables

This section is empty.

Functions

func CodingTypeFromExtension

func CodingTypeFromExtension(ext string) (string, error)

func Decode

func Decode(codingType string, b []byte, v interface{}) error

func DecodeJSON

func DecodeJSON(b []byte, v interface{}) error

func DecodeMsgPack

func DecodeMsgPack(b []byte, v interface{}) error

func DecodeTOML

func DecodeTOML(b []byte, v interface{}) error

func DecodeYAML

func DecodeYAML(b []byte, v interface{}) error

func Encode

func Encode(codingType string, v interface{}) ([]byte, error)

func EncodeJSON

func EncodeJSON(v interface{}) ([]byte, error)

func EncodeMsgPack

func EncodeMsgPack(v interface{}) ([]byte, error)

func EncodePrettyJSON

func EncodePrettyJSON(v interface{}) ([]byte, error)

func EncodeTOML

func EncodeTOML(v interface{}) ([]byte, error)

func EncodeYAML

func EncodeYAML(v interface{}) ([]byte, error)

func Print

func Print(kind string, v interface{})

func PrintJSON

func PrintJSON(v interface{})

func PrintTOML

func PrintTOML(v interface{})

func PrintYAML

func PrintYAML(v interface{})

func ReadFile

func ReadFile(v interface{}, filename string) error

func ReadFileEx

func ReadFileEx(codingType string, v interface{}, filename string) error

func WriteFile

func WriteFile(v interface{}, filename string) error

func WriteFileEx

func WriteFileEx(codingType string, v interface{}, filename string) error

Types

type Coding

type Coding interface {
	Encode(v interface{}) ([]byte, error)
	Decode(d []byte, v interface{}) error
}

func CodingFromType

func CodingFromType(codingType string) (Coding, error)

type JSONCoding

type JSONCoding struct {
}

func (*JSONCoding) Decode

func (coder *JSONCoding) Decode(b []byte, v interface{}) error

func (*JSONCoding) Encode

func (coder *JSONCoding) Encode(v interface{}) ([]byte, error)

type JSONPrettyCoding

type JSONPrettyCoding struct {
}

func (*JSONPrettyCoding) Decode

func (coder *JSONPrettyCoding) Decode(b []byte, v interface{}) error

func (*JSONPrettyCoding) Encode

func (coder *JSONPrettyCoding) Encode(v interface{}) ([]byte, error)

type MsgPackCoding

type MsgPackCoding struct {
}

func (*MsgPackCoding) Decode

func (coder *MsgPackCoding) Decode(b []byte, v interface{}) error

func (*MsgPackCoding) Encode

func (coder *MsgPackCoding) Encode(v interface{}) ([]byte, error)

type TomlCoding

type TomlCoding struct {
}

func (*TomlCoding) Decode

func (coder *TomlCoding) Decode(b []byte, v interface{}) error

func (*TomlCoding) Encode

func (coder *TomlCoding) Encode(v interface{}) ([]byte, error)

type YamlCoding

type YamlCoding struct {
}

func (*YamlCoding) Decode

func (coder *YamlCoding) Decode(b []byte, v interface{}) error

func (*YamlCoding) Encode

func (coder *YamlCoding) Encode(v interface{}) ([]byte, error)

Jump to

Keyboard shortcuts

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