Standard library / io/fs
fs.ValidPath()
Checks UTF-8 slash-separated relative names, allowing root dot but rejecting empty elements and dot-dot. Does not establish authorization or symlink confinement. Expected stdout: 'true false true\n'.
Formal Syntax & Structure
go syntaxgo
func ValidPath(name string) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Slash-separated filesystem path. |
Return Value
bool
Checks UTF-8 slash-separated relative names, allowing root dot but rejecting empty elements and dot-dot.
Working Example
Example Snippetgo
package main
import ( "fmt" "io/fs")
func main() { fmt.Println(fs.ValidPath("a/b"), fs.ValidPath("../a"), fs.ValidPath(".")) }