func (m *Macaroon) Clone() *Macaroon {
	m1 := *m
	m1.m = m1.m.Clone()
	m1.caveatData = make(map[string][]byte)
	for id, data := range m.caveatData {
		m1.caveatData[id] = data
	}
	return &m1
}
Clone returns a copy of the macaroon. Note that the the new
macaroon's namespace still points to the same underlying Namespace -
copying the macaroon does not make a copy of the namespace.
package bakery
import (
	"bytes"
	"encoding/base64"
	"encoding/binary"
	"encoding/json"
	"golang.org/x/net/context"
	"gopkg.in/errgo.v1"
	"gopkg.in/macaroon.v2"
	"gopkg.in/macaroon-bakery.v2/bakery/checkers"
)
func legacyNamespace() *checkers.Namespace {
	ns := checkers.NewNamespace(nil)
	ns.Register(checkers.StdNamespace, "")
	return ns
}
type Macaroon struct {
	m *macaroon.Macaroon
	version Version
	caveatData map[string][]byte
	namespace *checkers.Namespace
	caveatIdPrefix []byte
}
func NewLegacyMacaroon(m *macaroon.Macaroon) (*Macaroon, error) {
	v, err := bakeryVersion(m.Version())
	if err != nil {
		return nil, errgo.Mask(err)
	}
	return &Macaroon{
		m:         m,
		version:   v,
		namespace: legacyNamespace(),
	}, nil
}
type macaroonJSON struct {
	Macaroon *macaroon.Macaroon `json:"m"`
	Version  Version            `json:"v"`
	CaveatData map[string]string   `json:"cdata,omitempty"`
	Namespace  *checkers.Namespace `json:"ns"`
}