# README
:source-highlighter: pygments :pygments-style: manni
= Output Package Alessandro Sanino [email protected]
This package provides structs and helpers to be used in the rest of the project.
Usually it is paired to link:../https://github.com/bcmi-labs/arduino-cli/common/formatter[Formatter Package]
== Output structs Any Output struct must implement a set of functions, depending on the formatter.
In the case of TextFormatter and JSONFormatter. [source, go]
String() string // For Text Formatter. marshalJSON() ([]byte, error) // For JSON formatter.
Normally marshalJSON()
is already implemented using JSON Go Tags if using structs.
=== Example of correct output structs This is a correct example about how to build an output struct:
[source, go]
// ExampleOutput is a struct which implements Formattable
// JSON tags are used automatically by marshalJSON.
type ExampleOutput struct {
ExampleOfField interface{} json:"exampleOfField"
ExampleOfAnotherField int json:"ExampleOfAnotherField"
ExampleOfRequiredField string json:"ExampleOfRequiredField,required"
ExampleOfOptionalField string json:"ExampleOfOptionalField,omitempty"
}