diff --git a/altsrc/yaml_command_test.go b/altsrc/yaml_command_test.go index c7ccbf7..275bc64 100644 --- a/altsrc/yaml_command_test.go +++ b/altsrc/yaml_command_test.go @@ -1,7 +1,7 @@ // Disabling building of yaml support in cases where golang is 1.0 or 1.1 // as the encoding library is not implemented or supported. -// +build !go1,!go1.1 +// +build go1.2 package altsrc diff --git a/altsrc/yaml_file_loader.go b/altsrc/yaml_file_loader.go index 1251aeb..4fb0965 100644 --- a/altsrc/yaml_file_loader.go +++ b/altsrc/yaml_file_loader.go @@ -1,7 +1,7 @@ // Disabling building of yaml support in cases where golang is 1.0 or 1.1 // as the encoding library is not implemented or supported. -// +build !go1,!go1.1 +// +build go1.2 package altsrc @@ -23,19 +23,19 @@ type yamlSourceContext struct { // NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath. func NewYamlSourceFromFile(file string) (InputSourceContext, error) { - ymlLoader := &yamlSourceLoader{FilePath: file} + ysc := &yamlSourceContext{FilePath: file} var results map[string]interface{} - err := readCommandYaml(ysl.FilePath, &results) + err := readCommandYaml(ysc.FilePath, &results) if err != nil { - return fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", filePath, err.Error()) + return nil, fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", ysc.FilePath, err.Error()) } return &MapInputSource{valueMap: results}, nil } // NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context. -func NewYamlSourceFromFlagFunc(flagFileName string) func(InputSourceContext, error) { - return func(context cli.Context) { +func NewYamlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) { + return func(context *cli.Context) (InputSourceContext, error) { filePath := context.String(flagFileName) return NewYamlSourceFromFile(filePath) }