From fe87b2c7cb6087b12cd68311f2985b1ea9ab6d56 Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Fri, 26 Mar 2021 17:08:00 +0100 Subject: [PATCH] Fix format of StdoutSink --- sinks/stdoutSink.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/sinks/stdoutSink.go b/sinks/stdoutSink.go index ba8f56f..d110411 100644 --- a/sinks/stdoutSink.go +++ b/sinks/stdoutSink.go @@ -1,10 +1,10 @@ package sinks import ( - "fmt" - "time" - "strings" - "math" + "fmt" + "math" + "strings" + "time" ) type StdoutSink struct { @@ -21,24 +21,24 @@ func (s *StdoutSink) Init(host string, port string, user string, password string } func (s *StdoutSink) Write(measurement string, tags map[string]string, fields map[string]interface{}, t time.Time) error { - var tagsstr []string - var fieldstr []string - for k,v := range tags { - tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", k, v)) - } - for k,v := range fields { - if !math.IsNaN(v.(float64)) { - fieldstr = append(fieldstr, fmt.Sprintf("%s=%v", k, v.(float64))) - } - } - if len(tagsstr) > 0 { - fmt.Printf("%s,%s %s %d\n", measurement, strings.Join(tagsstr, ","), strings.Join(fieldstr, ","), t.Unix()) - } else { - fmt.Printf("%s %s %d\n", measurement, strings.Join(fieldstr, ","), t.Unix()) - } - return nil + var tagsstr []string + var fieldstr []string + for k, v := range tags { + tagsstr = append(tagsstr, fmt.Sprintf("%s=%s", k, v)) + } + for k, v := range fields { + if !math.IsNaN(v.(float64)) { + fieldstr = append(fieldstr, fmt.Sprintf("%s=%v", k, v.(float64))) + } + } + if len(tagsstr) > 0 { + fmt.Printf("%s,%s %s %d\n", measurement, strings.Join(tagsstr, ","), strings.Join(fieldstr, ","), t.Unix()) + } else { + fmt.Printf("%s %s %d\n", measurement, strings.Join(fieldstr, ","), t.Unix()) + } + return nil } func (s *StdoutSink) Close() { - return + return }