fastpath

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 1 Imported by: 4

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	B []byte // B is the underlying byte buffer
	// 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) Absolute

func (b *Builder) Absolute() bool

Absolute returns whether current path is absolute (not relative)

func (*Builder) Append

func (b *Builder) Append(p []byte)

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

func (*Builder) AppendString

func (b *Builder) AppendString(path string)

AppendString 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) Bytes

func (b *Builder) Bytes() []byte

Bytes returns the accumulated path bytes.

func (*Builder) Cap

func (b *Builder) Cap() int

Cap returns the capacity of the underlying Builder buffer

func (*Builder) Clean

func (b *Builder) Clean(path string) string

Clean creates the shortest possible functional equivalent to the supplied path, resetting the builder before performing this operation. The builder object is NOT reset after return

func (*Builder) Guarantee

func (b *Builder) Guarantee(size int)

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

func (*Builder) Join

func (b *Builder) Join(base string, paths ...string) string

Join connects and cleans multiple paths, resetting the builder before performing this operation and returning the shortest possible combination of all the supplied paths. The builder object is NOT reset after return

func (*Builder) Len

func (b *Builder) Len() int

Len returns the number of accumulated bytes in the Builder

func (*Builder) Reset

func (b *Builder) Reset()

Reset resets the Builder object

func (*Builder) SetAbsolute

func (b *Builder) SetAbsolute(val bool)

SetAbsolute converts the current path to / from absolute

func (*Builder) String

func (b *Builder) String() string

String returns the accumulated path string.

func (*Builder) StringPtr

func (b *Builder) StringPtr() string

StringPtr returns a ptr to 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 .String() if this is undesired behaviour.

func (*Builder) Truncate

func (b *Builder) Truncate(size int)

Truncate reduces the length of the buffer by the requested number of bytes. If the builder is set to absolute, the first byte (i.e. '/') will never be truncated

Jump to

Keyboard shortcuts

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