README
¶
OS X XML Plist library for Go
The plist library is used for decoding and encoding XML Plists, usually from HTTP streams.
Example:
func someHTTPHandler(w http.ResponseWriter, r *http.Request) {
var sparseBundleHeader struct {
InfoDictionaryVersion *string `plist:"CFBundleInfoDictionaryVersion"`
BandSize *uint64 `plist:"band-size"`
BackingStoreVersion int `plist:"bundle-backingstore-version"`
DiskImageBundleType string `plist:"diskimage-bundle-type"`
Size uint64 `plist:"unknownKey"`
}
// decode an HTTP request body into the sparseBundleHeader struct
if err := plist.NewXMLDecoder(r.Body).Decode(&sparseBundleHeader); err != nil {
log.Println(err)
return
}
}
Credit
This library is based of DHowett's library but has an API that's more similar to the XML and JSON libraries in the standard library. The plist.Decoder() accepts an io.Reader
instead of an io.ReadSeeker
Documentation
¶
Index ¶
- Constants
- func Marshal(v interface{}) ([]byte, error)
- func MarshalIndent(v interface{}, indent string) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
- type Decoder
- type Encoder
- type MarshalFunc
- type Marshaler
- type UnmarshalTypeError
- type Unmarshaler
- type UnsupportedTypeError
- type UnsupportedValueError
Constants ¶
const ( Invalid plistKind = iota Dictionary Array String Integer Real Boolean Data Date )
Variables ¶
This section is empty.
Functions ¶
func MarshalIndent ¶
MarshalIndent ...
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes Apple plist objects from an input stream. The plists can be in XML or binary format.
func NewBinaryDecoder ¶
func NewBinaryDecoder(r io.ReadSeeker) *Decoder
NewBinaryDecoder returns a new decoder that reads a binary plist from r. No error checking is done to make sure that r is actually a binary plist.
func NewDecoder ¶
NewDecoder returns a new XML plist decoder. DEPRECATED: Please use NewXMLDecoder instead.
func NewXMLDecoder ¶
NewXMLDecoder returns a new decoder that reads an XML plist from r.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder ...
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
type MarshalFunc ¶
type MarshalFunc func(interface{}) error
MarshalFunc is a function used to Unmarshal custom plist types.
type UnmarshalTypeError ¶
type UnmarshalTypeError struct { Value string // description of plist value - "true", "string", "date" Type reflect.Type }
An UnmarshalTypeError describes a plist value that was not appropriate for a value of a specific Go type.
func (UnmarshalTypeError) Error ¶
func (e UnmarshalTypeError) Error() string
type Unmarshaler ¶
type UnsupportedTypeError ¶
An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
type UnsupportedValueError ¶
UnsupportedValueError ...
func (*UnsupportedValueError) Error ¶
func (e *UnsupportedValueError) Error() string