Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal is a one-off interface to serialize a single object to a writer.
Most notably, this will *not* separate stanzas with a newline as is expected upon repeated calls, please use the Encoder streaming interface for that.
Given a struct (or list of structs), write to the io.Writer stream in the RFC822-alike Debian control-file format
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a struct that allows for the streaming Encoding of data back out to an `io.Writer`. Most notably, this will separate subsequent `Encode` calls of a Struct with a newline.
Given a struct (or list of structs), write to the io.Writer stream in the RFC822-alike Debian control-file format
In order to Marshal a custom Struct, you are required to implement the Marshallable interface. It's highly encouraged to put this interface on the struct without a pointer receiver, so that pass-by-value works when you call Marshal.
func NewEncoder ¶
Create a new Encoder, which is configured to write to the given `io.Writer`. Optionally, you can pass in a private key to sign the output with.
type Stanza ¶
A Stanza is a block of RFC2822-like key value pairs. This struct contains two methods to fetch values, a Map called Values, and a Slice called Order, which maintains the ordering as defined in the RFC2822-like block
func (Stanza) MarshalJSON ¶
MarshalJSON ensures the keys are marshaled in the order specified by Order
func (*Stanza) UnmarshalJSON ¶
UnmarshalJSON ensures the keys are unmarshaled and ordered as they appear in the JSON object
type StanzaReader ¶
type StanzaReader struct {
// contains filtered or unexported fields
}
Wrapper to allow iteration on a set of stanzas without consuming them all into memory at one time. This is also the level in which data is signed, so information such as the entity that signed these documents can be read by calling the `.Signer` method on this struct. The next unread stanza can be returned by calling the `.Next` method on this struct.
func NewStanzaReader ¶
func NewStanzaReader(reader io.Reader, keyring openpgp.EntityList) (*StanzaReader, error)
Create a new StanzaReader from the given `io.Reader`, and `keyring`. if `keyring` is set to `nil`, this will result in all OpenPGP signature checking being disabled. *including* that the contents match!
Also keep in mind, `reader` may be consumed 100% in memory due to the underlying OpenPGP API being hella fiddly.
func (*StanzaReader) All ¶
func (pr *StanzaReader) All() ([]Stanza, error)
func (*StanzaReader) Next ¶
func (pr *StanzaReader) Next() (*Stanza, error)
Consume the io.Reader and return the next parsed stanza, modulo garbage lines causing us to return an error.
func (*StanzaReader) Signer ¶
func (pr *StanzaReader) Signer() *openpgp.Entity
Return the Entity (if one exists) that signed this set of stanzas.