From f63e9130608b186623579b4961d72072a094a7b6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 18 Jun 2015 11:05:21 -0700 Subject: [PATCH] Remove path.Join usage as its not portable Thanks to Mattn for inputs --- cmd_test.go | 19 +++++++++---------- config.go | 12 ++++++------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/cmd_test.go b/cmd_test.go index f15f47e9..c8bc8d43 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -21,7 +21,6 @@ import ( "io" "io/ioutil" "os" - "path" "path/filepath" "runtime" "testing" @@ -83,7 +82,7 @@ func (s *CmdTestSuite) TestNewConfigV1(c *C) { conf, err := newConfig() c.Assert(err, IsNil) - configFile := path.Join(root, "config.json") + configFile := filepath.Join(root, "config.json") err = conf.Save(configFile) c.Assert(err, IsNil) @@ -158,9 +157,9 @@ func (s *CmdTestSuite) TestGetMcConfigDir(c *C) { case "freebsd": fallthrough case "darwin": - c.Assert(dir, Equals, path.Join(customConfigDir, mcConfigDir)) + c.Assert(dir, Equals, filepath.Join(customConfigDir, mcConfigDir)) case "windows": - c.Assert(dir, Equals, path.Join(customConfigDir, mcConfigWindowsDir)) + c.Assert(dir, Equals, filepath.Join(customConfigDir, mcConfigWindowsDir)) default: c.Fail() } @@ -172,13 +171,13 @@ func (s *CmdTestSuite) TestGetMcConfigPath(c *C) { c.Assert(err, IsNil) switch runtime.GOOS { case "linux": - c.Assert(dir, Equals, path.Join(mustGetMcConfigDir(), "config.json")) - case "windows": - c.Assert(dir, Equals, path.Join(mustGetMcConfigDir(), "config.json")) - case "darwin": - c.Assert(dir, Equals, path.Join(mustGetMcConfigDir(), "config.json")) + fallthrough case "freebsd": - c.Assert(dir, Equals, path.Join(mustGetMcConfigDir(), "config.json")) + fallthrough + case "darwin": + c.Assert(dir, Equals, filepath.Join(mustGetMcConfigDir(), "config.json")) + case "windows": + c.Assert(dir, Equals, filepath.Join(mustGetMcConfigDir(), "config.json")) default: c.Fail() } diff --git a/config.go b/config.go index 851b40e3..537e722d 100644 --- a/config.go +++ b/config.go @@ -19,7 +19,7 @@ package main import ( "os" "os/user" - "path" + "path/filepath" "runtime" "sync" @@ -45,9 +45,9 @@ func getMcConfigDir() (string, error) { // For windows the path is slightly different switch runtime.GOOS { case "windows": - return path.Join(customConfigDir, mcConfigWindowsDir), nil + return filepath.Join(customConfigDir, mcConfigWindowsDir), nil default: - return path.Join(customConfigDir, mcConfigDir), nil + return filepath.Join(customConfigDir, mcConfigDir), nil } } u, err := user.Current() @@ -57,9 +57,9 @@ func getMcConfigDir() (string, error) { // For windows the path is slightly different switch runtime.GOOS { case "windows": - return path.Join(u.HomeDir, mcConfigWindowsDir), nil + return filepath.Join(u.HomeDir, mcConfigWindowsDir), nil default: - return path.Join(u.HomeDir, mcConfigDir), nil + return filepath.Join(u.HomeDir, mcConfigDir), nil } } @@ -82,7 +82,7 @@ func getMcConfigPath() (string, error) { if err != nil { return "", iodine.New(err, nil) } - return path.Join(dir, mcConfigFile), nil + return filepath.Join(dir, mcConfigFile), nil } // mustGetMcConfigPath - similar to getMcConfigPath, ignores errors