The docs for filepath.Clean state the following:
...
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 '/'.
There is no mention that this function cannot be used for security, or that it does not safely ensure a path can't refer to a parent directory.A quick reading of 3 and 4 will make you assume that a path has no ".."s after being "Clean"d. If you actually think about it more, you'll realize that of course it will leave ".." at the beginning of relative paths, but the docs do not make it clear, and I can understand why a programmer might reach for this.
There's no clearer function to reach for either, like "filepath.DirectoryContains(parent, path) bool".