func sliceBundleTag(data []byte) ([]byte, error) {
	bundleTag := append([]byte(BundleTag), 0)
	if len(data) < len(bundleTag) {
		return nil, errors.Errorf("expected %q, got %q", bundleTag, data)
	}
	idx := bytes.Index(data, bundleTag)
	if idx == -1 {
		return nil, errors.Errorf("expected %q, got %q", bundleTag, data[:len(bundleTag)])
	}
	return data[len(bundleTag):], nil
}
sliceBundleTag slices the bundle tag off the data.
If the bundle tag is not present or is not correct, an error is returned.
package osc
import (
	"bytes"
	"encoding/binary"
	"net"
	"github.com/pkg/errors"
)
const (
	BundleTag = "#bundle"
)
var (
	ErrEarlyTimetag = errors.New("enclosing bundle's timetag was later than the nested bundle's")
	ErrEndOfPackets = errors.New("end of packets")
)
type Bundle struct {
	Timetag Timetag
	Packets []Packet
	Sender  net.Addr
}
func ParseBundle(data []byte, sender net.Addr) (Bundle, error) {
	return parseBundle(data, sender, -1)
}
func parseBundle(data []byte, sender net.Addr, limit int32) (Bundle, error) {
	b := Bundle{}
	if (limit >= 0) && (limit < int32(len(BundleTag)+1+TimetagSize)) {
		return b, errors.New("limit must be >= 16 or < 0")
	}
	data, err := sliceBundleTag(data)
	if err != nil {
		return b, errors.Wrap(err, "slice bundle tag")
	}
	tt, err := ReadTimetag(data)
	if err != nil {
		return b, errors.Wrap(err, "read timetag")
	}
	b.Timetag = tt
	data = data[8:]
	if limit == 16 {
		return b, nil
	}
	packets, err := readPackets(data, sender, limit-16)
	if err != nil {
		return b, errors.Wrap(err, "read packets")
	}
	b.Packets = packets
	return b, nil
}
func (b Bundle) Bytes() []byte {
	bss := [][]byte{
		ToBytes(BundleTag),
		b.Timetag.Bytes(),
	}
	for _, p := range b.Packets {
		var (
			bs     = p.Bytes()
			length = Int(int32(len(bs)))
		)
		bss = append(bss, length.Bytes(), p.Bytes())
	}
	return bytes.Join(bss, []byte{})
}
func (b Bundle) Equal(other Packet) bool {
	b2, ok := other.(Bundle)
	if !ok {
		return false
	}
	if b.Timetag != b2.Timetag {
		return false
	}
	if len(b.Packets) != len(b2.Packets) {
		return false
	}
	for i, p := range b.Packets {
		if !p.Equal(b2.Packets[i]) {
			return false
		}
	}
	return true
}