forked from mirror/client_golang
Merge pull request #211 from andrewstuart/variadic-register
Add *RegisterAll functions with variadic args
This commit is contained in:
commit
28be15864e
|
@ -115,11 +115,13 @@ func Register(m Collector) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustRegister works like Register but panics where Register would have
|
// MustRegister works like Register but panics where Register would have
|
||||||
// returned an error.
|
// returned an error. MustRegister is also Variadic, where Register only
|
||||||
func MustRegister(m Collector) {
|
// accepts a single Collector to register.
|
||||||
err := Register(m)
|
func MustRegister(m ...Collector) {
|
||||||
if err != nil {
|
for i := range m {
|
||||||
panic(err)
|
if err := Register(m[i]); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue