Package path implements utility routines for manipulating slash-separated paths. The path package should only be used for paths separated by forward slashes, such as the paths in URLs. This package does not deal with Windows paths with drive letters or backslashes; to manipulate operating system paths, use the path/filepath package.
Package filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths.
The filepath package uses either forward slashes or backslashes,depending on the operating system. To process paths such as URLs that always use forward slashes regardless of the operating system, see the path package.
Clean returns the shortest path name equivalent to path by purely lexical processing. It applies the following rules iteratively until no further processing can be done: 1. Replace multiple Separator elements with a single one. 2. Eliminate each . path name element (the current directory). 3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it. 4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path, assuming Separator is '/'. The returned path ends in a slash only if it represents a root directory, such as "/" on Unix or `C:\` on Windows. Finally, any occurrences of slash are replaced by Separator. If the result of this process is an empty string, Clean returns the string ".". See also Rob Pike, ``Lexical File Names in Plan 9 or Getting Dot-Dot Right,'' https://9p.io/sys/doc/lexnames.html