forked from mirror/client_golang
Extend MustRegister function to accept variadic args
This commit is contained in:
parent
9f1ed1ed4a
commit
e63e6e3db7
|
@ -115,13 +115,15 @@ func Register(m Collector) error {
|
|||
}
|
||||
|
||||
// MustRegister works like Register but panics where Register would have
|
||||
// returned an error.
|
||||
func MustRegister(m Collector) {
|
||||
err := Register(m)
|
||||
if err != nil {
|
||||
// returned an error. MustRegister is also Variadic, where Register only
|
||||
// accepts a single Collector to register.
|
||||
func MustRegister(m ...Collector) {
|
||||
for i := range m {
|
||||
if err := Register(m[i]); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterOrGet works like Register but does not return an error if a Collector
|
||||
// is registered that equals a previously registered Collector. (Two Collectors
|
||||
|
|
Loading…
Reference in New Issue