Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bminer committed Jan 23, 2019
1 parent 0fb5693 commit fe384b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
9 changes: 4 additions & 5 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func decode(influxResult []influxModels.Row, result interface{}) error {
}

config := &mapstructure.DecoderConfig{
Metadata: nil,
Result: result,
TagName: "influx",
Metadata: nil,
Result: result,
TagName: "influx",
WeaklyTypedInput: false,
ZeroFields: false,
ZeroFields: false,
DecodeHook: func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
if t == reflect.TypeOf(time.Time{}) && f == reflect.TypeOf("") {
return time.Parse(time.RFC3339, data.(string))
Expand All @@ -54,4 +54,3 @@ func decode(influxResult []influxModels.Row, result interface{}) error {

return decoder.Decode(influxData)
}

26 changes: 13 additions & 13 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func TestEncodeSetsMesurment(t *testing.T) {

func TestEncodeUsesTimeField(t *testing.T) {
type MyType struct {
MyTimeField time.Time `influx:"my_time_field"`
Val string `influx:"val"`
MyTimeField time.Time `influx:"my_time_field"`
Val string `influx:"val"`
}

td, _ := time.Parse(time.RFC822, "27 Oct 78 15:04 PST")

d := &MyType{td,"test-data"}
d := &MyType{td, "test-data"}
tv, _, _, _, err := encode(d, &usingValue{"my_time_field", false})

if tv != td {
Expand All @@ -52,16 +52,16 @@ func TestEncodeUsesTimeField(t *testing.T) {

func TestEncode(t *testing.T) {
type MyType struct {
InfluxMeasurement Measurement
Time time.Time `influx:"time"`
TagValue string `influx:"tagValue,tag"`
TagAndFieldValue string `influx:"tagAndFieldValue,tag,field"`
IntValue int `influx:"intValue"`
FloatValue float64 `influx:"floatValue"`
BoolValue bool `influx:"boolValue"`
StringValue string `influx:"stringValue"`
StructFieldName string `influx:""`
IgnoredValue string `influx:"-"`
InfluxMeasurement Measurement
Time time.Time `influx:"time"`
TagValue string `influx:"tagValue,tag"`
TagAndFieldValue string `influx:"tagAndFieldValue,tag,field"`
IntValue int `influx:"intValue"`
FloatValue float64 `influx:"floatValue"`
BoolValue bool `influx:"boolValue"`
StringValue string `influx:"stringValue"`
StructFieldName string `influx:""`
IgnoredValue string `influx:"-"`
}

d := MyType{
Expand Down

0 comments on commit fe384b5

Please sign in to comment.