func (e *EncoderRegistry) RegisterEncoder(format string, enc Encoder) error {
	e.mu.Lock()
	defer e.mu.Unlock()
	if _, ok := e.encoders[format]; ok {
		return ErrEncoderFormatAlreadyRegistered
	}
	e.encoders[format] = enc
	return nil
}
RegisterEncoder registers an Encoder for a format.
Registering a Encoder for an already existing format is not supported.
package encoding
import (
	"sync"
)
type Encoder interface {
	Encode(v interface{}) ([]byte, error)
}
const (
	ErrEncoderNotFound = encodingError("encoder not found for this format")
	ErrEncoderFormatAlreadyRegistered = encodingError("encoder already registered for this format")
)
type EncoderRegistry struct {
	encoders map[string]Encoder
	mu sync.RWMutex
}
func NewEncoderRegistry() *EncoderRegistry {
	return &EncoderRegistry{
		encoders: make(map[string]Encoder),
	}
}