pathutil

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllExt added in v0.11.0

func AllExt(path string) string

AllExt returns all extensions (e.g., ".tar.gz" instead of ".gz") from the file name (including ".").

func ChangeParent added in v0.10.0

func ChangeParent(srcPath string, srcDir string, dstDir string) (dstPath string, err error)

ChangeParent changes the parent of srcPath from srcDir to dstDir, and returns the dstPath. If srcPath is not a child of srcDir, it returns an error.

For example

ChangeParent("/home/user/dir/file.txt", "/home", "/root") // -> "/root/user/dir/file.txt"
ChangeParent("/home/user/file.txt", "/home/user", "/home/user/dir") // -> "/home/user/dir/file.txt"

func Glob added in v1.6.0

func Glob(pattern []string, root string) ([]string, error)

func Match added in v1.6.0

func Match(pattern string, name string) (bool, error)

func MatchAny added in v1.6.0

func MatchAny(patterns []string, name string) (bool, error)

func MustChangeParent added in v0.10.0

func MustChangeParent(srcPath string, srcDir string, dstDir string) string

MustChangeParent calls ChangeParent and panics if an error occurs. It is safe to use MustChangeParent in, for example, os.WalkDir.

func RemoveAllExt added in v0.10.0

func RemoveAllExt(path string) string

RemoveAllExt returns the path without all extensions.

func RemoveExt added in v0.8.0

func RemoveExt(path string) string

RemoveExt returns the path without the extension.

func ReplaceAllExt added in v0.10.0

func ReplaceAllExt(path string, ext string) string

ReplaceAllExt replaces all extensions of the given path with the given extension.

func ReplaceExt

func ReplaceExt(path string, ext string) string

ReplaceExt replaces the extension of the given path with the given extension.

func Splits added in v0.11.1

func Splits(path string) (parts []string)

func Stem added in v0.16.0

func Stem(path string) string

Stem returns the name of the path without the extension (e.g. foo.bar.zip -> foo).

Types

This section is empty.

Jump to

Keyboard shortcuts

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