func (bsc *BaseStableCollector) init(self StableCollector) {
	bsc.self = self
	dch := make(chan *Desc)
	go func() {
		bsc.self.DescribeWithStability(dch)
		close(dch)
	}()
	for d := range dch {
		bsc.add(d)
	}
}
Init intends to be called by registry.
package metrics
import (
	"fmt"
	"github.com/blang/semver"
	"github.com/prometheus/client_golang/prometheus"
)
type StableCollector interface {
	prometheus.Collector
	DescribeWithStability(chan<- *Desc)
	CollectWithStability(chan<- Metric)
	Create(version *semver.Version, self StableCollector) bool
	ClearState()
	HiddenMetrics() []string
}
type BaseStableCollector struct {
	descriptors  map[string]*Desc  
	registerable map[string]*Desc  
	hidden       map[string]*Desc  
	self         StableCollector
}
func (bsc *BaseStableCollector) DescribeWithStability(ch chan<- *Desc) {
	panic(fmt.Errorf("custom collector should over-write DescribeWithStability method"))
}
func (bsc *BaseStableCollector) Describe(ch chan<- *prometheus.Desc) {
	for _, d := range bsc.registerable {
		ch <- d.toPrometheusDesc()
	}
}
func (bsc *BaseStableCollector) CollectWithStability(ch chan<- Metric) {
	panic(fmt.Errorf("custom collector should over-write CollectWithStability method"))
}
func (bsc *BaseStableCollector) Collect(ch chan<- prometheus.Metric) {
	mch := make(chan Metric)
	go func() {
		bsc.self.CollectWithStability(mch)
		close(mch)
	}()
	for m := range mch {
		if m == nil {
			continue
		}
		ch <- prometheus.Metric(m)
	}
}
func (bsc *BaseStableCollector) add(d *Desc) {
	if len(d.fqName) == 0 {
		panic("nameless metrics will be not allowed")
	}
	if bsc.descriptors == nil {
		bsc.descriptors = make(map[string]*Desc)
	}
	if _, exist := bsc.descriptors[d.fqName]; exist {
		panic(fmt.Sprintf("duplicate metrics (%s) will be not allowed", d.fqName))
	}
	bsc.descriptors[d.fqName] = d
}