Skip to content

Commit

Permalink
Fix fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Samylkin committed Mar 11, 2017
1 parent fcf0f29 commit e6cbfc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions config/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ package config

import (
"bytes"
"fmt"
"encoding"
"fmt"
"reflect"
"strconv"

Expand Down Expand Up @@ -309,7 +309,7 @@ func (d *decoder) textUnmarshaller(key string, value reflect.Value, str string)
v := d.getGlobalProvider().Get(key)
if v.HasValue() {
str = v.String()
} else if str == "" {
} else if str == "" {
return nil
}

Expand All @@ -318,7 +318,7 @@ func (d *decoder) textUnmarshaller(key string, value reflect.Value, str string)
}

// Value has to have a pointer receiver to be able to modify itself with TextUnmarshaller
switch t := value.Addr().Interface().(type){
switch t := value.Addr().Interface().(type) {
case encoding.TextUnmarshaler:
return t.UnmarshalText([]byte(str))
}
Expand Down
22 changes: 11 additions & 11 deletions config/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ package config

import (
"bytes"
"fmt"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
Expand Down Expand Up @@ -666,7 +666,7 @@ Say:

type unmarshallerChan chan string

func (m *unmarshallerChan) UnmarshalText(text []byte) error{
func (m *unmarshallerChan) UnmarshalText(text []byte) error {
name := string(text)
if name == "error" {
return errors.New("unmarshaller channel error")
Expand All @@ -678,7 +678,7 @@ func (m *unmarshallerChan) UnmarshalText(text []byte) error{

type unmarshallerFunc func(string) error

func (m *unmarshallerFunc) UnmarshalText(text []byte) error{
func (m *unmarshallerFunc) UnmarshalText(text []byte) error {
str := string(text)
if str == "error" {
return errors.New("unmarshaller function error")
Expand All @@ -701,7 +701,7 @@ func TestHappyUnmarshallerChannelFunction(t *testing.T) {
var r Chart
p := NewYAMLProviderFromBytes(src)
require.NoError(t, p.Get(Root).PopulateStruct(&r))
require.Equal(t, band, <- r.Band)
require.Equal(t, band, <-r.Band)
assert.EqualError(t, r.Song("Get "), song)
}

Expand All @@ -711,12 +711,12 @@ Song: off my cloud
`)

tests := map[string]func(){
"defaults":func(){f([]byte(``), "Hello Beatles", "Get back")},
"custom values":func(){f(b, "Hello Rolling Stones", "Get off my cloud")},
"defaults": func() { f([]byte(``), "Hello Beatles", "Get back") },
"custom values": func() { f(b, "Hello Rolling Stones", "Get off my cloud") },
}

for k, v := range tests {
t.Run(k, func(*testing.T){v()})
t.Run(k, func(*testing.T) { v() })
}
}

Expand Down Expand Up @@ -745,11 +745,11 @@ F: error
`)

tests := map[string]func(){
"channel error":func(){f(chanError, "unmarshaller channel error")},
"function error":func(){f(funcError, "unmarshaller function error")},
"channel error": func() { f(chanError, "unmarshaller channel error") },
"function error": func() { f(funcError, "unmarshaller function error") },
}

for k, v := range tests {
t.Run(k, func(*testing.T){v()})
t.Run(k, func(*testing.T) { v() })
}
}
}

0 comments on commit e6cbfc5

Please sign in to comment.