path

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultPathDelimiter denotes the character used to separate directory and file names in paths.
	DefaultPathDelimiter = filepath.Separator
)

Variables

View Source
var (
	// Err occurs when using malformed paths.
	Err = errors.New("Malformed path")
)

Functions

func Abs

func Abs(path string) (string, errors.Error)

Abs retrieves the full path to a relative path.

func AbsIn

func AbsIn(wd, path string) (string, errors.Error)

AbsIn returns the absolute path as seen by a given working directory. The working directory is ignored for absolute paths.

func AbsRoot

func AbsRoot(root, path string) (string, errors.Error)

AbsRoot returns the absolute path and ensures the result to stay in root.

func Base

func Base(path string) string

Base returns only the last part of a path.

func BaseNoExt

func BaseNoExt(path string) string

BaseNoExt returns only the last part of a path excluding the file extension as returned by Ext.

func Clean

func Clean(path string) string

Clean removes all navigation parts (. and ..) and removes empty path parts.

func Dir

func Dir(path string) string

Dir returns the parent directory of a path.

func Ext

func Ext(path string) string

Ext returns the file extensions including the dot character.

func IsAbs

func IsAbs(path string) bool

IsAbs returns whether the path is absolute.

func IsIn

func IsIn(path, expectedParent string) (bool, errors.Error)

IsIn returns true when the given path is a (recursive) child of expectedParent. This method can be used for security checks.

func Join

func Join(parts ...string) string

Join merges multiple path parts using the DefaultPathDelimiter.

func NoExt

func NoExt(path string) string

NoExt removes the file extension as returned by Ext.

Types

This section is empty.

Jump to

Keyboard shortcuts

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