Use filepath.Join in locale resource getting
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 7 Feb 2016 01:12:33 +0000 (02:12 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 7 Feb 2016 01:12:33 +0000 (02:12 +0100)
tpl/template_resources.go

index 30c7f589be8cef580b45ebaa4c652d679d5a0aa7..204c0f39fa88ed79830235d6317e40e1918138a5 100644 (file)
@@ -158,15 +158,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
 
 // resGetLocal loads the content of a local file
 func resGetLocal(url string, fs afero.Fs) ([]byte, error) {
-       p := ""
-       workingDir := viper.GetString("WorkingDir")
-       if workingDir != "" {
-               p = workingDir
-               if !strings.HasSuffix(p, helpers.FilePathSeparator) {
-                       p = p + helpers.FilePathSeparator
-               }
-       }
-       filename := p + url
+       filename := filepath.Join(viper.GetString("WorkingDir"), url)
        if e, err := helpers.Exists(filename, fs); !e {
                return nil, err
        }