Documentation
¶
Overview ¶
Package format provides a registry and interfaces for output formatters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrFormat is the base error for formatter failures. ErrFormat = fmt.Errorf("format error") // ErrNoSerializer indicates a payload does not implement any supported serializer. ErrNoSerializer = fmt.Errorf("message is not serializable") )
Functions ¶
func GetFormats ¶
func GetFormats() []string
GetFormats returns the list of registered formatter names.
func RegisterFormatDriver ¶
func RegisterFormatDriver(name string, t FormatDriver)
RegisterFormatDriver registers and prepares a formatter under a name.
Types ¶
type DriverFormatError ¶
DriverFormatError wraps a driver-specific error with its formatter name.
func (*DriverFormatError) Error ¶
func (e *DriverFormatError) Error() string
func (*DriverFormatError) Unwrap ¶
func (e *DriverFormatError) Unwrap() []error
type Format ¶
type Format struct {
FormatDriver
// contains filtered or unexported fields
}
Format is a named formatter wrapper used by the registry.
func FindFormat ¶
FindFormat returns a configured formatter by name.
type FormatDriver ¶
type FormatDriver interface {
Prepare() error // Prepare driver (eg: flag registration)
Init() error // Initialize driver (eg: parse keying)
Format(data interface{}) ([]byte, []byte, error) // Send a message
}
FormatDriver describes a formatter plugin lifecycle and output method.
type FormatInterface ¶
FormatInterface is the minimal interface needed to format payloads.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package binary implements binary output formatting using encoding.BinaryMarshaler.
|
Package binary implements binary output formatting using encoding.BinaryMarshaler. |
|
Package json implements JSON output formatting.
|
Package json implements JSON output formatting. |
|
Package text implements text output formatting.
|
Package text implements text output formatting. |
Click to show internal directories.
Click to hide internal directories.