path

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

README

Alternative path library with a strings.Builder like path builder.

Benchmarks compared to "path":

benchmarks

Better documentation + README in progress...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base(path string) string

Base only returns the file name of a path, i.e. only the part after the last '/'

func Clean

func Clean(path string) string

Clean a path

func Dir

func Dir(path string) string

Dir returns all of a path up to the last '/'

func IsAbs

func IsAbs(path string) bool

IsAbs returns whether a path is absolute

func Join

func Join(path1, path2 string) string

Join cleans and joins two paths

Types

type Builder

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

func NewBuilder

func NewBuilder(b []byte) *Builder

NewBuilder returns a new Builder object using the supplied byte slice as the underlying buffer

func (*Builder) Append

func (b *Builder) Append(path string)

Append adds and cleans the supplied path string to the builder's internal buffer, growing the buffer if necessary to accomodate the extra path length

func (*Builder) Cap

func (b *Builder) Cap() int

Cap returns the capacity of the underlying Builder buffer

func (*Builder) Grow added in v0.1.3

func (b *Builder) Grow(size int)

Grow ensures there is at least the requested size free bytes available in the buffer, reallocating if necessary

func (*Builder) Len

func (b *Builder) Len() int

Len returns the number of accumulated bytes in the Builder

func (*Builder) NewString added in v0.1.2

func (b *Builder) NewString() string

NewString returns a freshly allocated copy of the accumulated path string

func (*Builder) Reset

func (b *Builder) Reset()

Reset resets the Builder object

func (*Builder) String

func (b *Builder) String() string

String returns the accumulated path string.

Please note the underlying byte slice for this string is tied to the builder, so any changes will result in the returned string changing. Consider using .NewString() if this is undesired behaviour.

Jump to

Keyboard shortcuts

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