Merge pull request #211 from andrewstuart/variadic-register

Add *RegisterAll functions with variadic args
This commit is contained in:
Björn Rabenstein 2016-07-12 00:22:38 +02:00 committed by GitHub
commit 28be15864e
1 changed files with 7 additions and 5 deletions

View File

@ -115,12 +115,14 @@ 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