func NewDecoder(r io.ReadSeeker) *Decoder {
	return &Decoder{Format: InvalidFormat, reader: r, lax: false}
}
NewDecoder returns a Decoder that reads property list elements from a stream reader, r.
NewDecoder requires a Seekable stream for the purposes of file type detection.
package plist
import (
	"bytes"
	"io"
	"reflect"
	"runtime"
)
type parser interface {
	parseDocument() (cfValue, error)
}
type Decoder struct {
	Format int
	reader io.ReadSeeker
	lax    bool
}
func (p *Decoder) Decode(v interface{}) (err error) {
	defer func() {
		if r := recover(); r != nil {
			if _, ok := r.(runtime.Error); ok {
				panic(r)
			}
			err = r.(error)
		}
	}()
	header := make([]byte, 6)
	p.reader.Read(header)
	p.reader.Seek(0, 0)
	var parser parser
	var pval cfValue
	if bytes.Equal(header, []byte("bplist")) {
		parser = newBplistParser(p.reader)
		pval, err = parser.parseDocument()
		if err != nil {
			return err
		}
		p.Format = BinaryFormat
	} else {
		parser = newXMLPlistParser(p.reader)
		pval, err = parser.parseDocument()
		if _, ok := err.(invalidPlistError); ok {
			p.reader.Seek(0, 0)
			tp := newTextPlistParser(p.reader)
			pval, err = tp.parseDocument()
			if err != nil {
				return err
			}
			p.Format = tp.format
			if p.Format == OpenStepFormat {
				p.lax = true
			}
		} else {
			if err != nil {
				return err
			}
			p.Format = XMLFormat
		}
	}
	p.unmarshal(pval, reflect.ValueOf(v))
	return
}