From cacd8a78b3691d2e3bee251b2d85644593f55ef0 Mon Sep 17 00:00:00 2001 From: Chris Hines Date: Mon, 14 Dec 2015 14:59:19 -0500 Subject: [PATCH] Use minimum OS specific path. This change ensures LoadConfig and LoadConfigDir report consistent paths to files and those paths use the appropriate path separator for the target OS. Note that LoadConfigDir constructs paths with filepath.Join, which calls filepath.Clean, which calls filepath.FromSlash. --- command/agent/config.go | 2 +- command/agent/config_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/command/agent/config.go b/command/agent/config.go index e3fb3ae17..8ee166842 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -613,7 +613,7 @@ func LoadConfig(path string) (*Config, error) { if fi.IsDir() { return LoadConfigDir(path) } - return LoadConfigFile(path) + return LoadConfigFile(filepath.Clean(path)) } // LoadConfigString is used to parse a config string diff --git a/command/agent/config_test.go b/command/agent/config_test.go index e342b997b..f89386a95 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -327,7 +327,7 @@ func TestConfig_LoadConfigsFileOrder(t *testing.T) { config := config1.Merge(config2) if !reflect.DeepEqual(config.Files, expected) { - t.Errorf("Loaded configs don't match\nExpected\n%+vGot\n%+v\n", + t.Errorf("Loaded configs don't match\nwant: %+v\n got: %+v\n", expected, config.Files) } }