From ba5b46217c3cdc34bf45ae247df02468644285b7 Mon Sep 17 00:00:00 2001 From: DazWilkin Date: Sun, 31 Jul 2016 17:30:34 -0700 Subject: [PATCH] Fixed Go formatting --- .../webhooks/particle/particle_webhooks.go | 4 +- .../particle/particle_webhooks_mocks.go | 34 +++++++------- .../particle/particle_webhooks_models.go | 44 +++++++++---------- .../particle/particle_webhooks_test.go | 14 +++--- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/plugins/inputs/webhooks/particle/particle_webhooks.go b/plugins/inputs/webhooks/particle/particle_webhooks.go index 29153c499..1303c05ad 100644 --- a/plugins/inputs/webhooks/particle/particle_webhooks.go +++ b/plugins/inputs/webhooks/particle/particle_webhooks.go @@ -25,7 +25,7 @@ func (pwh *ParticleWebhook) Register(router *mux.Router, acc telegraf.Accumulato func (pwh *ParticleWebhook) eventHandler(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() - if err := r.ParseForm(); err != nil { + if err := r.ParseForm(); err != nil { w.WriteHeader(http.StatusBadRequest) return } @@ -46,4 +46,4 @@ func NewEvent(r *http.Request, event Event) (Event, error) { return nil, err } return event, nil -} \ No newline at end of file +} diff --git a/plugins/inputs/webhooks/particle/particle_webhooks_mocks.go b/plugins/inputs/webhooks/particle/particle_webhooks_mocks.go index 9bd6d9e79..c128ad417 100644 --- a/plugins/inputs/webhooks/particle/particle_webhooks_mocks.go +++ b/plugins/inputs/webhooks/particle/particle_webhooks_mocks.go @@ -1,31 +1,31 @@ package particle import ( - "fmt" - "math/rand" - "net/url" - "time" + "fmt" + "math/rand" + "net/url" + "time" ) const hexBytes = "0123456789abcdef" func init() { - rand.Seed(time.Now().UnixNano()) + rand.Seed(time.Now().UnixNano()) } func RandStringBytes(n int) string { - b := make([]byte, n) - for i := range b { - b[i] = hexBytes[rand.Intn(len(hexBytes))] - } - return string(b) + b := make([]byte, n) + for i := range b { + b[i] = hexBytes[rand.Intn(len(hexBytes))] + } + return string(b) } func NewEventURLEncoded() string { - rand.Seed(time.Now().UnixNano()) - return fmt.Sprintf("event=%v&data=%v&published_at=%v&coreid=%v", - "event", - rand.Intn(1000), - url.QueryEscape(time.Now().Format(time.RFC3339)), - RandStringBytes(24)) -} \ No newline at end of file + rand.Seed(time.Now().UnixNano()) + return fmt.Sprintf("event=%v&data=%v&published_at=%v&coreid=%v", + "event", + rand.Intn(1000), + url.QueryEscape(time.Now().Format(time.RFC3339)), + RandStringBytes(24)) +} diff --git a/plugins/inputs/webhooks/particle/particle_webhooks_models.go b/plugins/inputs/webhooks/particle/particle_webhooks_models.go index ecac43aa1..1f550a56d 100644 --- a/plugins/inputs/webhooks/particle/particle_webhooks_models.go +++ b/plugins/inputs/webhooks/particle/particle_webhooks_models.go @@ -15,37 +15,37 @@ type Event interface { } type ParticleEvent struct { - Event string `schema:"event"` - Data int `schema:"data"` - PublishedAt time.Time `schema:"published_at"` - CoreID string `schema:"coreid"` + Event string `schema:"event"` + Data int `schema:"data"` + PublishedAt time.Time `schema:"published_at"` + CoreID string `schema:"coreid"` } func (pe ParticleEvent) String() string { - return fmt.Sprintf(` + return fmt.Sprintf(` Event == { event: %v, data: %v, published: %v, coreid: %v }`, - pe.Event, - pe.Data, - pe.PublishedAt, - pe.CoreID) + pe.Event, + pe.Data, + pe.PublishedAt, + pe.CoreID) } func (pe ParticleEvent) NewMetric() telegraf.Metric { - t := map[string]string{ - "event": pe.Event, - "coreid": pe.CoreID, - } - f := map[string]interface{}{ - "data": pe.Data, - } - m, err := telegraf.NewMetric(pe.Event, t, f, pe.PublishedAt) - if err != nil { - log.Fatalf("Failed to create %v event", meas) - } - return m -} \ No newline at end of file + t := map[string]string{ + "event": pe.Event, + "coreid": pe.CoreID, + } + f := map[string]interface{}{ + "data": pe.Data, + } + m, err := telegraf.NewMetric(pe.Event, t, f, pe.PublishedAt) + if err != nil { + log.Fatalf("Failed to create %v event", meas) + } + return m +} diff --git a/plugins/inputs/webhooks/particle/particle_webhooks_test.go b/plugins/inputs/webhooks/particle/particle_webhooks_test.go index 7f594538a..479d6fd1d 100644 --- a/plugins/inputs/webhooks/particle/particle_webhooks_test.go +++ b/plugins/inputs/webhooks/particle/particle_webhooks_test.go @@ -1,16 +1,16 @@ package particle import ( - "net/http" - "net/http/httptest" - "testing" + "net/http" + "net/http/httptest" + "testing" - "github.com/influxdata/telegraf/testutil" + "github.com/influxdata/telegraf/testutil" ) func ParticleWebhookRequest(urlEncodedString string, t *testing.T) { var acc testutil.Accumulator - pwh:= &ParticleWebhook{Path: "/particle", acc: &acc} + pwh := &ParticleWebhook{Path: "/particle", acc: &acc} req, _ := http.NewRequest("POST", "/particle", urlEncodedString) w := httptest.NewRecorder() pwh.eventHandler(w, req) @@ -20,5 +20,5 @@ func ParticleWebhookRequest(urlEncodedString string, t *testing.T) { } func TestNewEvent(t *testing.T) { - ParticleWebhookRequest(NewEventURLEncoded()) -} \ No newline at end of file + ParticleWebhookRequest(NewEventURLEncoded()) +}