path

package
v1.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(v string) (string, error)

func Base

func Base(src string) string

func Clean

func Clean(src string) string

func Dir

func Dir(path string) string

Dir returns all but the last element of path, typically the path's directory. After dropping the final element, Dir calls Clean on the path and trailing slashes are removed. If the path is empty, Dir returns ".". If the path consists entirely of separators, Dir returns a single separator. The returned path does not end in a separator unless it is the root directory.

func DirPath

func DirPath(src string) string

func Ext

func Ext(src string) string

Ext returns the file name extension used by path. The extension is the suffix beginning at the final dot in the final element of path; it is empty if there is no dot.

func IsAbs

func IsAbs(path string) bool

func IsLocal

func IsLocal(path string) bool

func Join

func Join(v ...string) string

func Split

func Split(src string) (dir string, file string)

Split splits path immediately following the final Separator, separating it into a directory and file name component. If there is no Separator in path, Split returns an empty dir and file set to path.

The returned values have the property that path = dir+file.

func Walk added in v1.20.0

func Walk(root string, fn WalkFunc, opts ...walker.Option) error

Walk wraps WalkWithContext using the background context.

func WalkWithContext added in v1.20.0

func WalkWithContext(ctx context.Context, root string, fn WalkFunc, opts ...walker.Option) error

WalkWithContext walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root.

If fastWalk returns filepath.SkipDir, the directory is skipped.

Multiple goroutines stat the filesystem concurrently. The provided walkFn must be safe for concurrent use.

func WithErrorCallback added in v1.20.0

func WithErrorCallback(call WalkCallback) walker.Option

WithErrorCallback sets a callback to be used for error handling. Any error returned will halt the Walk function and return the error. If the callback returns nil Walk will continue.

Types

type WalkCallback added in v1.20.0

type WalkCallback func(pathname string, err error) error

type WalkFunc added in v1.20.0

type WalkFunc func(pathname string, fi os.FileInfo) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL