Documentation
¶
Index ¶
- Constants
- func Base(sep uint8, volumeName func(string) string, path string) string
- func Clean(sep uint8, volumeName func(string) string, path string) string
- func Dir(sep uint8, volumeName func(string) string, path string) string
- func Ext(sep uint8, path string) string
- func FromSlash(sep uint8, path string) string
- func Join(sep uint8, volumeName func(string) string, elem ...string) string
- func Match(sep uint8, pattern, name string) (matched bool, err error)
- func Split(sep uint8, volumeName func(string) string, path string) (dir, file string)
- func ToSlash(sep uint8, path string) string
- type Renderer
- type UnixRenderer
- func (ur UnixRenderer) Base(path string) string
- func (ur UnixRenderer) Clean(path string) string
- func (ur UnixRenderer) Dir(path string) string
- func (UnixRenderer) Ext(path string) string
- func (UnixRenderer) FromSlash(path string) string
- func (UnixRenderer) IsAbs(path string) bool
- func (ur UnixRenderer) Join(path ...string) string
- func (UnixRenderer) Match(pattern, name string) (matched bool, err error)
- func (UnixRenderer) NormCase(path string) string
- func (ur UnixRenderer) Split(path string) (dir, file string)
- func (UnixRenderer) SplitList(path string) []string
- func (UnixRenderer) SplitSuffix(path string) (string, string)
- func (UnixRenderer) ToSlash(path string) string
- func (UnixRenderer) VolumeName(path string) string
- type WindowsRenderer
- func (ur WindowsRenderer) Base(path string) string
- func (ur WindowsRenderer) Clean(path string) string
- func (ur WindowsRenderer) Dir(path string) string
- func (WindowsRenderer) Ext(path string) string
- func (WindowsRenderer) FromSlash(path string) string
- func (WindowsRenderer) IsAbs(path string) bool
- func (ur WindowsRenderer) Join(path ...string) string
- func (WindowsRenderer) Match(pattern, name string) (matched bool, err error)
- func (WindowsRenderer) NormCase(path string) string
- func (ur WindowsRenderer) Split(path string) (dir, file string)
- func (WindowsRenderer) SplitList(path string) []string
- func (WindowsRenderer) SplitSuffix(path string) (string, string)
- func (WindowsRenderer) ToSlash(path string) string
- func (WindowsRenderer) VolumeName(path string) string
Constants ¶
const ( UnixSeparator = '/' // OS-specific path separator UnixListSeparator = ':' // OS-specific path list separator )
const ( WindowsSeparator = '\\' // OS-specific path separator WindowsListSeparator = ';' // OS-specific path list separator )
Variables ¶
This section is empty.
Functions ¶
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-Separator characters
'?' matches any single non-Separator 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 returned error is ErrBadPattern, when pattern is malformed.
On Windows, escaping is disabled. Instead, '\\' is treated as path separator.
Types ¶
type Renderer ¶
type Renderer interface {
// Base mimics path/filepath.
Base(path string) string
// Clean mimics path/filepath.
Clean(path string) string
// Dir mimics path/filepath.
Dir(path string) string
// Ext mimics path/filepath.
Ext(path string) string
// FromSlash mimics path/filepath.
FromSlash(path string) string
// IsAbs mimics path/filepath.
IsAbs(path string) bool
// Join mimics path/filepath.
Join(path ...string) string
// Match mimics path/filepath.
Match(pattern, name string) (matched bool, err error)
// NormCase normalizes the case of a pathname. On Unix and Mac OS X,
// this returns the path unchanged; on case-insensitive filesystems,
// it converts the path to lowercase.
NormCase(path string) string
// Split mimics path/filepath.
Split(path string) (dir, file string)
// SplitList mimics path/filepath.
SplitList(path string) []string
// SplitSuffix splits the pathname into a pair (root, suffix) such
// that root + suffix == path, and ext is empty or begins with a
// period and contains at most one period. Leading periods on the
// basename are ignored; SplitSuffix('.cshrc') returns ('.cshrc', ”).
SplitSuffix(path string) (string, string)
// ToSlash mimics path/filepath.
ToSlash(path string) string
// VolumeName mimics path/filepath.
VolumeName(path string) string
}
Renderer provides methods for the different functions in the stdlib path/filepath package that don't relate to a concrete filesystem. So Abs, EvalSymlinks, Glob, Rel, and Walk are not included. Also, while the functions in path/filepath relate to the current host, the PathRenderer methods relate to the renderer's target platform. So for example, a windows-oriented implementation will give windows-specific results even when used on linux.
func NewRenderer ¶
NewRenderer returns a Renderer for the given os.
type UnixRenderer ¶
type UnixRenderer struct{}
UnixRenderer is a Renderer implementation for most flavors of Unix.
func (UnixRenderer) Base ¶
func (ur UnixRenderer) Base(path string) string
Base implements Renderer.
func (UnixRenderer) Clean ¶
func (ur UnixRenderer) Clean(path string) string
Clean implements Renderer.
func (UnixRenderer) FromSlash ¶
func (UnixRenderer) FromSlash(path string) string
FromSlash implements Renderer.
func (UnixRenderer) Join ¶
func (ur UnixRenderer) Join(path ...string) string
Join implements Renderer.
func (UnixRenderer) Match ¶
func (UnixRenderer) Match(pattern, name string) (matched bool, err error)
Match implements Renderer.
func (UnixRenderer) NormCase ¶
func (UnixRenderer) NormCase(path string) string
NormCase implements Renderer.
func (UnixRenderer) Split ¶
func (ur UnixRenderer) Split(path string) (dir, file string)
Split implements Renderer.
func (UnixRenderer) SplitList ¶
func (UnixRenderer) SplitList(path string) []string
SplitList implements Renderer.
func (UnixRenderer) SplitSuffix ¶
func (UnixRenderer) SplitSuffix(path string) (string, string)
SplitSuffix implements Renderer.
func (UnixRenderer) ToSlash ¶
func (UnixRenderer) ToSlash(path string) string
ToSlash implements Renderer.
func (UnixRenderer) VolumeName ¶
func (UnixRenderer) VolumeName(path string) string
VolumeName implements Renderer.
type WindowsRenderer ¶
type WindowsRenderer struct{}
WindowsRenderer is a Renderer implementation for Windows.
func (WindowsRenderer) Base ¶
func (ur WindowsRenderer) Base(path string) string
Base implements Renderer.
func (WindowsRenderer) Clean ¶
func (ur WindowsRenderer) Clean(path string) string
Clean implements Renderer.
func (WindowsRenderer) Dir ¶
func (ur WindowsRenderer) Dir(path string) string
Dir implements Renderer.
func (WindowsRenderer) Ext ¶
func (WindowsRenderer) Ext(path string) string
Ext implements Renderer.
func (WindowsRenderer) FromSlash ¶
func (WindowsRenderer) FromSlash(path string) string
FromSlash implements Renderer.
func (WindowsRenderer) IsAbs ¶
func (WindowsRenderer) IsAbs(path string) bool
IsAbs implements Renderer.
func (WindowsRenderer) Join ¶
func (ur WindowsRenderer) Join(path ...string) string
Join implements Renderer.
func (WindowsRenderer) Match ¶
func (WindowsRenderer) Match(pattern, name string) (matched bool, err error)
Match implements Renderer.
func (WindowsRenderer) NormCase ¶
func (WindowsRenderer) NormCase(path string) string
NormCase implements Renderer.
func (WindowsRenderer) Split ¶
func (ur WindowsRenderer) Split(path string) (dir, file string)
Split implements Renderer.
func (WindowsRenderer) SplitList ¶
func (WindowsRenderer) SplitList(path string) []string
SplitList implements Renderer.
func (WindowsRenderer) SplitSuffix ¶
func (WindowsRenderer) SplitSuffix(path string) (string, string)
SplitSuffix implements Renderer.
func (WindowsRenderer) ToSlash ¶
func (WindowsRenderer) ToSlash(path string) string
ToSlash implements Renderer.
func (WindowsRenderer) VolumeName ¶
func (WindowsRenderer) VolumeName(path string) string
VolumeName implements Renderer.