path_windows.go
1package platform
2
3import "strings"
4
5// ToPosixPath returns the input, converting any backslashes to forward ones.
6func ToPosixPath(in string) string {
7 // strings.Map only allocates on change, which is good enough especially as
8 // path.Join uses forward slash even on windows.
9 return strings.Map(windowsToPosixSeparator, in)
10}
11
12func windowsToPosixSeparator(r rune) rune {
13 if r == '\\' {
14 return '/'
15 }
16 return r
17}