// encode encodes a snapshots object into a slice of bytes.
encode encodes a snapshots object into a slice of bytes.
// encode encodes a snapshots object into a slice of bytes .
func encode(snaps snapshots) ([]byte, error) {
	var buf bytes.Buffer
	var err error
	ids := []string{}
	for id := range snaps {
		ids = append(ids, string(id))
	}
	sort.Strings(ids)
	for _, id := range ids {
		s := snaps[snapshotID(id)]
		_, err = buf.WriteString(fmt.Sprintf("%s%s */\n", snapshotSeparator, string(s.id)))
		if err != nil {
			return nil, err
		}
		_, err = buf.WriteString(fmt.Sprintf("%s\n\n", s.value))
		if err != nil {
			return nil, err
		}
	}
	return bytes.TrimSpace(buf.Bytes()), nil
}
func encode ( snaps snapshots ) ( [ ] byte , error ) { var buf bytes . Buffer var err error ids := [ ] string { } for id := range snaps { ids = append ( ids , string ( id ) ) } sort . Strings ( ids ) for _ , id := range ids { s := snaps [ snapshotID ( id ) ] _ , err = buf . WriteString ( fmt . Sprintf ( " \n " , snapshotSeparator , string ( s . id ) ) ) if err != nil { return nil , err } _ , err = buf . WriteString ( fmt . Sprintf ( " \n \n " , s . value ) ) if err != nil { return nil , err } } return bytes . TrimSpace ( buf . Bytes ( ) ) , nil }
encode encodes a snapshots object into a slice of bytes.
encode encodes a snapshots object into a slice of bytes .