pathx

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pathx provides additional utilities for working with paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CutPrefix

func CutPrefix(path, prefix string) (string, bool)

CutPrefix delegates the call to Setup.CutPrefix assuming Posix setup.

func CutSuffix

func CutSuffix(path, suffix string) (string, bool)

CutSuffix delegates the call to Setup.CutSuffix assuming Posix setup.

func ExplicitlyRelative

func ExplicitlyRelative(p string) string

ExplicitlyRelative delegates the call to Setup.ExplicitlyRelative assuming Posix setup.

func HasPrefix

func HasPrefix(path, prefix string) bool

HasPrefix delegates the call to Setup.HasPrefix assuming Posix setup.

func HasSuffix

func HasSuffix(path, suffix string) bool

HasSuffix delegates the call to Setup.HasSuffix assuming Posix setup.

Types

type Setup

type Setup struct {
	// contains filtered or unexported fields
}

Setup is a certain configuration of paths handling rules.

func OS

func OS() Setup

OS returns current operating system specific setup.

func Posix

func Posix() Setup

Posix returns operating system independent setup conforming `posix` standards.

func (Setup) CutPrefix

func (s Setup) CutPrefix(path, prefix string) (string, bool)

CutPrefix checks whether path has the given prefix and returns remaining path if it has. Path is considered to have a prefix only if the prefix hits at path delimiter boundary.

func (Setup) CutSuffix

func (s Setup) CutSuffix(path, suffix string) (string, bool)

CutSuffix checks whether path has the given suffix and returns remaining path if it has. Path is considered to have a suffix only if the suffix hits at path delimiter boundary.

func (Setup) ExplicitlyRelative

func (s Setup) ExplicitlyRelative(p string) string

ExplicitlyRelative checks if p is a relative path and ensures it has '.' or '..' prefix. If it doesn't, '.' prefix is added. If it is absolute, original value is returned.

func (Setup) HasPrefix

func (s Setup) HasPrefix(path, prefix string) bool

HasPrefix checks whether path has the given prefix. Path is considered to have a prefix only if the prefix hits at path delimiter boundary.

func (Setup) HasSuffix

func (s Setup) HasSuffix(path, suffix string) bool

HasSuffix checks whether path has the given suffix. Path is considered to have a suffix only if the suffix hits at path delimiter boundary.

Jump to

Keyboard shortcuts

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