Format code appropriately

This commit is contained in:
Regan Kuchan 2015-11-30 16:40:47 -08:00
parent cd5bcce2c2
commit 9e663d74da
2 changed files with 15 additions and 18 deletions

View File

@ -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} })
}
plugins.Add("Trig", func() plugins.Plugin { return &Trig{x: 0.0} })
}

View File

@ -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))
}
}