func (r *StandardRegistry) GetOrRegister(name string, i interface{}) interface{} {
	r.mutex.RLock()
	metric, ok := r.metrics[name]
	r.mutex.RUnlock()
	if ok {
		return metric
	}
	r.mutex.Lock()
	defer r.mutex.Unlock()
	if metric, ok := r.metrics[name]; ok {
		return metric
	}
	if v := reflect.ValueOf(i); v.Kind() == reflect.Func {
		i = v.Call(nil)[0].Interface()
	}
	r.register(name, i)
	return i
}
Gets an existing metric or creates and registers a new one. Threadsafe
alternative to calling Get and Register on failure.
The interface can be the metric to register if not found in registry,
or a function returning the metric for lazy instantiation.
package metrics
import (
	"fmt"
	"reflect"
	"strings"
	"sync"
)
type DuplicateMetric string
func (err DuplicateMetric) Error() string {
	return fmt.Sprintf("duplicate metric: %s", string(err))
}
type Registry interface {
	Each(func(string, interface{}))
	Get(string) interface{}
	GetAll() map[string]map[string]interface{}
	GetOrRegister(string, interface{}) interface{}
	Register(string, interface{}) error
	RunHealthchecks()
	Unregister(string)
	UnregisterAll()
}
type StandardRegistry struct {
	metrics map[string]interface{}
	mutex   sync.RWMutex
}
func NewRegistry() Registry {
	return &StandardRegistry{metrics: make(map[string]interface{})}
}
func (r *StandardRegistry) Each(f func(string, interface{})) {
	for name, i := range r.registered() {
		f(name, i)
	}
}
func (r *StandardRegistry) Get(name string) interface{} {
	r.mutex.RLock()
	defer r.mutex.RUnlock()
	return r.metrics[name]
}