Merge pull request #818 from harshavardhana/pr_out_remove_path_join_usage_as_its_not_portable
This commit is contained in:
+9
-10
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user