transcribe

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: Apache-2.0 Imports: 20 Imported by: 17

README

Transcribe for Go

License Go Reference Go Report Card

Go programs often need to output data in a structured representation format, such as JSON or YAML. But why not provide wider compatibility and support all common formats, letting the user choose? This library provides a unified API over several formats.

It also supports "pretty" printing to terminals with semantic colorization, including on Windows terminals, which defy common standards.

Binary formats (CBOR, MessagePack) can be output as is (incompatible with terminals) or textualized into Base64.

Supported formats:

Documentation

Index

Constants

View Source
const DIRECTORY_WRITE_PERMISSIONS = 0700
View Source
const FILE_WRITE_PERMISSIONS = 0600

Variables

View Source
var YAMLNodeKinds = map[yaml.Kind]string{
	yaml.DocumentNode: "Document",
	yaml.SequenceNode: "Sequence",
	yaml.MappingNode:  "Mapping",
	yaml.ScalarNode:   "Scalar",
	yaml.AliasNode:    "Alias",
}

Functions

func ColorizeYAML

func ColorizeYAML(code string, writer io.Writer) error

func DumpYAMLNode

func DumpYAMLNode(writer io.Writer, node *yaml.Node, indent int)

func DumpYAMLNodes

func DumpYAMLNodes(writer io.Writer, node *yaml.Node)

func NewJSONColorFormatter

func NewJSONColorFormatter(indent int) *prettyjson.Formatter

func NewUtterConfig

func NewUtterConfig(indent string) *utter.ConfigState

func OpenFileForWrite

func OpenFileForWrite(path string) (*os.File, error)

func Print

func Print(value any, format string, writer io.Writer, strict bool, pretty bool, base64 bool, reflector *ard.Reflector) error

func PrintCBOR

func PrintCBOR(value any, writer io.Writer, base64 bool) error

func PrintGo

func PrintGo(value any, writer io.Writer, pretty bool) error

func PrintJSON

func PrintJSON(value any, writer io.Writer, pretty bool) error

func PrintMessagePack

func PrintMessagePack(value any, writer io.Writer, base64 bool) error

func PrintXJSON

func PrintXJSON(value any, writer io.Writer, pretty bool, reflector *ard.Reflector) error

func PrintXML

func PrintXML(value any, writer io.Writer, pretty bool, reflector *ard.Reflector) error

func PrintXMLDocument

func PrintXMLDocument(xmlDocument *etree.Document, writer io.Writer, pretty bool) error

func PrintYAML

func PrintYAML(value any, writer io.Writer, strict bool, pretty bool, reflector *ard.Reflector) error

func Stringify

func Stringify(value any, format string, indent string, strict bool, reflector *ard.Reflector) (string, error)

func StringifyCBOR

func StringifyCBOR(value any) (string, error)

To Base64

func StringifyGo

func StringifyGo(value any, indent string) (string, error)

func StringifyJSON

func StringifyJSON(value any, indent string) (string, error)

func StringifyMessagePack

func StringifyMessagePack(value any) (string, error)

To Base64

func StringifyXJSON

func StringifyXJSON(value any, indent string, reflector *ard.Reflector) (string, error)

func StringifyXML

func StringifyXML(value any, indent string, reflector *ard.Reflector) (string, error)

func StringifyYAML

func StringifyYAML(value any, indent string, strict bool, reflector *ard.Reflector) (string, error)

func Validate

func Validate(code string, format string) error

func ValidateCBOR

func ValidateCBOR(code string) error

func ValidateJSON

func ValidateJSON(code string) error

func ValidateMessagePack

func ValidateMessagePack(code string) error

func ValidateXML

func ValidateXML(code string) error

func ValidateYAML

func ValidateYAML(code string) error

func Write

func Write(value any, format string, indent string, strict bool, writer io.Writer, base64 bool, reflector *ard.Reflector) error

func WriteCBOR

func WriteCBOR(value any, writer io.Writer, base64 bool) error

func WriteGo

func WriteGo(value any, writer io.Writer, indent string) error

func WriteJSON

func WriteJSON(value any, writer io.Writer, indent string) error

func WriteMessagePack

func WriteMessagePack(value any, writer io.Writer, base64 bool) error

func WriteOrPrint

func WriteOrPrint(value any, format string, writer io.Writer, strict bool, pretty bool, base64 bool, output string, reflector *ard.Reflector) error

func WriteXJSON

func WriteXJSON(value any, writer io.Writer, indent string, reflector *ard.Reflector) error

func WriteXML

func WriteXML(value any, writer io.Writer, indent string, reflector *ard.Reflector) error

func WriteXMLDocument

func WriteXMLDocument(xmlDocument *etree.Document, writer io.Writer, indent string) error

func WriteYAML

func WriteYAML(value any, writer io.Writer, indent string, strict bool, reflector *ard.Reflector) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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