Documentation
¶
Overview ¶
Package pathutil handles platform-independent project paths.
Index ¶
- Variables
- func Base(p string) string
- func Clean(p string) string
- func Dir(p string) string
- func EqualFold(a, b string) bool
- func Ext(p string) string
- func HasTraversal(rel string) bool
- func IsAbs(p string) bool
- func Join(elems ...string) string
- func SafeJoin(root, rel string) (string, error)
- func ToSlash(p string) string
- func VolumeName(p string) string
Constants ¶
This section is empty.
Variables ¶
var ErrTraversal = errors.New("pathutil: path escapes root")
ErrTraversal is returned when a relative path would escape its base directory via ".." segments.
Functions ¶
func Ext ¶
Ext returns the file extension of p, including the leading ".", or "" if p's base name has none.
func HasTraversal ¶
HasTraversal reports whether rel escapes through a ".." segment.
func IsAbs ¶
IsAbs reports whether p is absolute under Unix ("/foo"), Windows drive ("C:\foo", "C:/foo"), or UNC (`\\server\share`) conventions.
func ToSlash ¶
ToSlash normalizes path separators to "/", accepting both "/" and "\" in the input regardless of host OS.
func VolumeName ¶
VolumeName returns the Windows drive-letter volume prefix of p (e.g. "C:"), or "" if p has none.
Types ¶
This section is empty.