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 {
// URL is only for backwards compatability
Servers []string
Timeout int
Servers []string
Timeout int
conns []net.Conn
conns []net.Conn
serializer serializers.Serializer
}

View File

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

View File

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

View File

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

View File

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

View File

@ -490,14 +490,14 @@ func TestSerializerWithJsonProtocol2(t *testing.T) {
// then
actualS := string(buf)
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_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}" +
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_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}"+
"]", now.Unix(), now.Unix())
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_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}" +
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_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}"+
"]", now.Unix(), now.Unix())
// serialize function uses internally map. result is not same everytime because map is not guaranteed key ordering.

View File

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