Created
May 24, 2016 13:06
-
-
Save codemartial/10e0dfa5a7773c9fff17f5935bf771a6 to your computer and use it in GitHub Desktop.
Flattening expvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func FlattenVar(kv expvar.KeyValue, w io.Writer, prefix string) { | |
if m, ok := kv.Value.(*expvar.Map); ok { | |
m.Do(func(kv_ expvar.KeyValue) { FlattenVar(kv_, w, fmt.Sprintf("%s%s.", prefix, kv.Key)) }) | |
} else { | |
fmt.Fprintf(w, "\"%s%s\": %s\n", prefix, kv.Key, kv.Value) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment