Skip to content

Commit

Permalink
gofmt the code
Browse files Browse the repository at this point in the history
  • Loading branch information
zaa committed Nov 26, 2016
1 parent ab2277b commit 599ea08
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func NewFunctionalGauge(f func() int64) Gauge {
return &FunctionalGauge{value: f}
}


// NewRegisteredFunctionalGauge constructs and registers a new StandardGauge.
func NewRegisteredFunctionalGauge(name string, r Registry, f func() int64) Gauge {
c := NewFunctionalGauge(f)
Expand Down Expand Up @@ -101,6 +100,7 @@ func (g *StandardGauge) Update(v int64) {
func (g *StandardGauge) Value() int64 {
return atomic.LoadInt64(&g.value)
}

// FunctionalGauge returns value from given function
type FunctionalGauge struct {
value func() int64
Expand All @@ -117,4 +117,4 @@ func (g FunctionalGauge) Snapshot() Gauge { return GaugeSnapshot(g.Value()) }
// Update panics.
func (FunctionalGauge) Update(int64) {
panic("Update called on a FunctionalGauge")
}
}
2 changes: 1 addition & 1 deletion gauge_float64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestFunctionalGaugeFloat64(t *testing.T) {

func TestGetOrRegisterFunctionalGaugeFloat64(t *testing.T) {
r := NewRegistry()
NewRegisteredFunctionalGaugeFloat64("foo", r, func() float64 { return 47})
NewRegisteredFunctionalGaugeFloat64("foo", r, func() float64 { return 47 })
if g := GetOrRegisterGaugeFloat64("foo", r); 47 != g.Value() {
t.Fatal(g)
}
Expand Down
6 changes: 3 additions & 3 deletions registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ func NewPrefixedChildRegistry(parent Registry, prefix string) Registry {

// Call the given function for each registered metric.
func (r *PrefixedRegistry) Each(fn func(string, interface{})) {
wrappedFn := func (prefix string) func(string, interface{}) {
wrappedFn := func(prefix string) func(string, interface{}) {
return func(name string, iface interface{}) {
if strings.HasPrefix(name,prefix) {
if strings.HasPrefix(name, prefix) {
fn(name, iface)
} else {
return
Expand All @@ -184,7 +184,7 @@ func (r *PrefixedRegistry) Each(fn func(string, interface{})) {
func findPrefix(registry Registry, prefix string) (Registry, string) {
switch r := registry.(type) {
case *PrefixedRegistry:
return findPrefix(r.underlying, r.prefix + prefix)
return findPrefix(r.underlying, r.prefix+prefix)
case *StandardRegistry:
return r, prefix
}
Expand Down
3 changes: 1 addition & 2 deletions registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,8 @@ func TestWalkRegistries(t *testing.T) {
Register("bars", c)

_, prefix := findPrefix(r2, "")
if "prefix.prefix2." != prefix {
if "prefix.prefix2." != prefix {
t.Fatal(prefix)
}


}

0 comments on commit 599ea08

Please sign in to comment.