From 9e663d74da143ff315ddcd525e979fe7e25ddaa8 Mon Sep 17 00:00:00 2001 From: Regan Kuchan Date: Mon, 30 Nov 2015 16:40:47 -0800 Subject: [PATCH] Format code appropriately --- plugins/trig/trig.go | 17 ++++++++--------- plugins/trig/trig_test.go | 16 +++++++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/plugins/trig/trig.go b/plugins/trig/trig.go index 4c04daf8c..410bce9de 100644 --- a/plugins/trig/trig.go +++ b/plugins/trig/trig.go @@ -1,14 +1,14 @@ package trig import ( - "math" "fmt" + "math" "github.com/influxdb/telegraf/plugins" ) type Trig struct { - x float64 + x float64 Amplitude float64 } @@ -26,8 +26,8 @@ func (s *Trig) Description() string { } func (s *Trig) Gather(acc plugins.Accumulator) error { - sinner := math.Sin((s.x * math.Pi) / 5.0) * s.Amplitude - cosinner := math.Cos((s.x * math.Pi) / 5.0) * s.Amplitude + sinner := math.Sin((s.x*math.Pi)/5.0) * s.Amplitude + cosinner := math.Cos((s.x*math.Pi)/5.0) * s.Amplitude fields := make(map[string]interface{}) fields["sine"] = sinner @@ -36,15 +36,14 @@ func (s *Trig) Gather(acc plugins.Accumulator) error { tags := make(map[string]string) s.x += 1.0 - acc.AddFields("trig",fields,tags) + acc.AddFields("trig", fields, tags) - fmt.Printf("%#v\n",fields) + fmt.Printf("%#v\n", fields) return nil } - func init() { -plugins.Add("Trig", func() plugins.Plugin { return &Trig{x: 0.0} }) -} \ No newline at end of file + plugins.Add("Trig", func() plugins.Plugin { return &Trig{x: 0.0} }) +} diff --git a/plugins/trig/trig_test.go b/plugins/trig/trig_test.go index 5bd1fe79f..218cfad6c 100644 --- a/plugins/trig/trig_test.go +++ b/plugins/trig/trig_test.go @@ -1,9 +1,9 @@ package trig import ( - "testing" - "math" "fmt" + "math" + "testing" "github.com/influxdb/telegraf/testutil" "github.com/stretchr/testify/assert" @@ -15,13 +15,12 @@ func TestTrig(t *testing.T) { Amplitude: 10.0, } - - for i:=0.0; i < 10.0; i++ { + for i := 0.0; i < 10.0; i++ { var acc testutil.Accumulator - sine := math.Sin((i * math.Pi) / 5.0) * s.Amplitude - cosine := math.Cos((i * math.Pi) / 5.0) * s.Amplitude + sine := math.Sin((i*math.Pi)/5.0) * s.Amplitude + cosine := math.Cos((i*math.Pi)/5.0) * s.Amplitude s.Gather(&acc) @@ -29,10 +28,9 @@ func TestTrig(t *testing.T) { fields["sine"] = sine fields["cosine"] = cosine - fmt.Printf("%#v\n",fields) + fmt.Printf("%#v\n", fields) assert.True(t, acc.CheckFieldsValue("trig", fields)) - + } } -