Overall code formatting via go fmt command

This commit is contained in:
Dark(김성진) 2017-01-24 00:37:19 +09:00
parent 457d22c35c
commit 824029ae54
7 changed files with 24 additions and 24 deletions

View File

@ -14,10 +14,10 @@ import (
type Graphite struct { type Graphite struct {
// URL is only for backwards compatability // URL is only for backwards compatability
Servers []string Servers []string
Timeout int Timeout int
conns []net.Conn conns []net.Conn
serializer serializers.Serializer serializer serializers.Serializer
} }

View File

@ -11,9 +11,9 @@ import (
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins/serializers/graphite"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/influxdata/telegraf/plugins/serializers/graphite"
) )
func TestGraphiteError(t *testing.T) { func TestGraphiteError(t *testing.T) {

View File

@ -22,12 +22,12 @@ var (
) )
type Instrumental struct { type Instrumental struct {
Host string Host string
ApiToken string ApiToken string
Timeout internal.Duration Timeout internal.Duration
Debug bool Debug bool
conn net.Conn conn net.Conn
serializer serializers.Serializer serializer serializers.Serializer
} }
@ -210,7 +210,7 @@ func (i *Instrumental) authenticate(conn net.Conn) error {
func init() { func init() {
outputs.Add("instrumental", func() telegraf.Output { outputs.Add("instrumental", func() telegraf.Output {
return &Instrumental{ return &Instrumental{
Host: DefaultHost, Host: DefaultHost,
} }
}) })
} }

View File

@ -10,8 +10,8 @@ import (
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/metric"
"github.com/stretchr/testify/assert"
"github.com/influxdata/telegraf/plugins/serializers/graphite" "github.com/influxdata/telegraf/plugins/serializers/graphite"
"github.com/stretchr/testify/assert"
) )
func TestWrite(t *testing.T) { func TestWrite(t *testing.T) {

View File

@ -5,8 +5,8 @@ import (
"sort" "sort"
"strings" "strings"
"github.com/influxdata/telegraf"
"encoding/json" "encoding/json"
"github.com/influxdata/telegraf"
) )
const ( const (
@ -26,8 +26,8 @@ type GraphiteSerializer struct {
// GraphiteJson struct for json processing. // GraphiteJson struct for json processing.
type GraphiteJson struct { type GraphiteJson struct {
Path string `json:"path"` Path string `json:"path"`
Value string `json:"value"` Value string `json:"value"`
Timestamp string `json:"timestamp"` Timestamp string `json:"timestamp"`
} }
@ -54,8 +54,8 @@ func jsonSerialize(bucket string, metric telegraf.Metric, timestamp int64) ([]by
for fieldName, value := range metric.Fields() { for fieldName, value := range metric.Fields() {
out = append(out, GraphiteJson{ out = append(out, GraphiteJson{
Path: sanitizedChars.Replace(InsertField(bucket, fieldName)), Path: sanitizedChars.Replace(InsertField(bucket, fieldName)),
Value: sanitizedChars.Replace(fmt.Sprintf("%#v", value)), Value: sanitizedChars.Replace(fmt.Sprintf("%#v", value)),
Timestamp: fmt.Sprintf("%d", timestamp), Timestamp: fmt.Sprintf("%d", timestamp),
}) })
} }

View File

@ -490,14 +490,14 @@ func TestSerializerWithJsonProtocol2(t *testing.T) {
// then // then
actualS := string(buf) actualS := string(buf)
expS := fmt.Sprintf("[" + expS := fmt.Sprintf("["+
"{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}," + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"},"+
"{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}" + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}"+
"]", now.Unix(), now.Unix()) "]", now.Unix(), now.Unix())
reorderedExpS := fmt.Sprintf("[" + reorderedExpS := fmt.Sprintf("["+
"{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}," + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"},"+
"{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}" + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}"+
"]", now.Unix(), now.Unix()) "]", now.Unix(), now.Unix())
// serialize function uses internally map. result is not same everytime because map is not guaranteed key ordering. // serialize function uses internally map. result is not same everytime because map is not guaranteed key ordering.
@ -507,4 +507,4 @@ func TestSerializerWithJsonProtocol2(t *testing.T) {
} else { } else {
assert.True(t, false) assert.True(t, false)
} }
} }

View File

@ -67,7 +67,7 @@ func NewInfluxSerializer() (Serializer, error) {
} }
func NewGraphiteSerializer(prefix, template, protocol string) (Serializer, error) { func NewGraphiteSerializer(prefix, template, protocol string) (Serializer, error) {
return &graphite.GraphiteSerializer{ return &graphite.GraphiteSerializer{
Prefix: prefix, Prefix: prefix,
Template: template, Template: template,
Protocol: protocol, Protocol: protocol,