path.Clean.md (718B)
1 --- 2 title: path.Clean 3 description: Replaces path separators with slashes (`/`) and removes extraneous separators. 4 date: 2021-10-08 5 # publishdate: 2018-11-28 6 # lastmod: 2018-11-28 7 categories: [functions] 8 menu: 9 docs: 10 parent: "functions" 11 keywords: [path, clean] 12 signature: ["path.Clean PATH"] 13 relatedfuncs: [path.Base, path.BaseName, path.Dir, path.Ext, path.Join, path.Split] 14 --- 15 16 `path.Clean` replaces path separators with slashes (`/`) and removes extraneous separators, including trailing separators. 17 18 ``` 19 {{ path.Clean "foo//bar" }} → "foo/bar" 20 {{ path.Clean "/foo/bar/" }} → "/foo/bar" 21 ``` 22 23 On a Windows system, if `.File.Path` is `foo\bar.md`, then: 24 25 ``` 26 {{ path.Clean .File.Path }} → "foo/bar.md" 27 ```