shpath

package
v0.0.0-...-24ca9bf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NL = "\n"

	TAB     = "\t"
	PATHSEP = string(os.PathListSeparator)
)
View Source
const (
	ListSep = ":"
)

Variables

View Source
var NormalizeNL = normalizeNewlinesString

NormalizeNL normalizes newlines to the popular standard '\n' convention.

Any '\r\n' (a Windows convention) or '\r' (an older Apple convention) sequences are replaced with a single '\n'.

Several methods were profiled and the most efficient one is aliased to this function. YMMV; change the alias as you see fit =)

View Source
var Verbose bool = false

Functions

func DropDupeSeps

func DropDupeSeps(s string, sep string) string

DropDupeSeps replaces consecutive duplicates of only specific 'sep' strings with a single 'sep'

func GetEnvValue

func GetEnvValue(key string) (string, error)

func IsDir

func IsDir(s string) bool

func IsRegular

func IsRegular(s string) bool

Types

type ShPath

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

func NewPath

func NewPath() (*ShPath, error)

func (*ShPath) Add

func (p *ShPath) Add(s string, n int) error

Add checks that the directory exists and adds element s to the path at position n. If the position is not valid, s will be placed at the end of the list.

func (*ShPath) Clean

func (p *ShPath) Clean() (n int)

Clean removes invalid directories, and returns the number removed, if any. The order of the directories is maintained.

func (*ShPath) DebugPrint

func (p *ShPath) DebugPrint()

DebugPrint prints a numbered list of items.

func (*ShPath) Len

func (p *ShPath) Len() int

Len returns the number of items in the list.

func (ShPath) Load

func (p ShPath) Load() error

func (*ShPath) Out

func (p *ShPath) Out() string

Out returns the path in delimited format ready for OS use. Out runs Clean() on the list.

func (ShPath) Save

func (p ShPath) Save(path string) error

func (*ShPath) String

func (p *ShPath) String() string

String returns the path in newline delimited format. (pretty print)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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