pathutil

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 3 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 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)

Types

This section is empty.

Jump to

Keyboard shortcuts

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