windowsJoinPath joins the elements into a path, using Windows path separator and converting forward slashes to backslashes.
(elem ...string)
| 568 | // windowsJoinPath joins the elements into a path, using Windows path separator |
| 569 | // and converting forward slashes to backslashes. |
| 570 | func windowsJoinPath(elem ...string) string { |
| 571 | if runtime.GOOS == "windows" { |
| 572 | return filepath.Join(elem...) |
| 573 | } |
| 574 | |
| 575 | var s string |
| 576 | for _, e := range elem { |
| 577 | e = unixToWindowsPath(e) |
| 578 | if e == "" { |
| 579 | continue |
| 580 | } |
| 581 | if s == "" { |
| 582 | s = e |
| 583 | continue |
| 584 | } |
| 585 | s += "\\" + strings.TrimSuffix(e, "\\") |
| 586 | } |
| 587 | return s |
| 588 | } |
| 589 | |
| 590 | func unixToWindowsPath(p string) string { |
| 591 | return strings.ReplaceAll(p, "/", "\\") |
no test coverage detected