func (e Event) String() string {
	b := strings.Builder{}
	b.WriteString(e.Context.String())
	if e.DataEncoded != nil {
		if e.DataBase64 {
			b.WriteString("Data (binary),\n  ")
		} else {
			b.WriteString("Data,\n  ")
		}
		switch e.DataMediaType() {
		case ApplicationJSON:
			var prettyJSON bytes.Buffer
			err := json.Indent(&prettyJSON, e.DataEncoded, "  ", "  ")
			if err != nil {
				b.Write(e.DataEncoded)
			} else {
				b.Write(prettyJSON.Bytes())
			}
		default:
			b.Write(e.DataEncoded)
		}
		b.WriteString("\n")
	}
	return b.String()
}
String returns a pretty-printed representation of the Event.
package event
import (
	"bytes"
	"encoding/json"
	"strings"
)
type Event struct {
	Context     EventContext
	DataEncoded []byte
	DataBase64  bool
	FieldErrors map[string]error
}
const (
	defaultEventVersion = CloudEventsVersionV1
)
func (e *Event) fieldError(field string, err error) {
	if e.FieldErrors == nil {
		e.FieldErrors = make(map[string]error)
	}
	e.FieldErrors[field] = err
}
func (e *Event) fieldOK(field string) {
	if e.FieldErrors != nil {
		delete(e.FieldErrors, field)
	}
}
func New(version ...string) Event {
	specVersion := defaultEventVersion
	if len(version) >= 1 {
		specVersion = version[0]
	}
	e := &Event{}
	e.SetSpecVersion(specVersion)
	return *e
}
func (e Event) ExtensionAs(name string, obj interface{}) error {
	return e.Context.ExtensionAs(name, obj)
}