Documentation ¶
Overview ¶
Package path implements utility routines for manipulating slash-separated filename paths.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadPattern = os.NewError("syntax error in pattern")
Functions ¶
func Base ¶
Base returns the last element of path. Trailing slashes are removed before extracting the last element. If the path is empty, Base returns ".". If the path consists entirely of slashes, Base returns "/".
func Clean ¶
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:
- Replace multiple slashes with a single slash.
- Eliminate each . path name element (the current directory).
- Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
- Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.
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,” http://plan9.bell-labs.com/sys/doc/lexnames.html
func Ext ¶
Ext returns the file name extension used by path. The extension is the suffix beginning at the final dot in the final slash-separated element of path; it is empty if there is no dot.
func Join ¶
Join joins any number of path elements into a single path, adding a separating slash if necessary. All empty strings are ignored.
func Match ¶
Match returns true if name matches the shell file name pattern. The pattern syntax is:
pattern: { term } term: '*' matches any sequence of non-/ characters '?' matches any single non-/ character '[' [ '^' ] { character-range } ']' character class (must be non-empty) c matches character c (c != '*', '?', '\\', '[') '\\' c matches character c character-range: c matches character c (c != '\\', '-', ']') '\\' c matches character c lo '-' hi matches character c for lo <= c <= hi
Match requires pattern to match all of name, not just a substring. The only possible error return is when pattern is malformed.
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths.
|
Package filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths. |