paths

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package paths hosts the interface used by pina-golada to parse and concat relative and absolute file paths. It wraps around the raw path string to provide easy management of complex paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPathSeparator

func GetPathSeparator() string

GetPathSeparator returns the paths separator of the current os

Types

type MemoryPath

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

MemoryPath implements the Path interface

func Of

func Of(path string) *MemoryPath

Of creates a paths off of a string

func (*MemoryPath) Clone

func (m *MemoryPath) Clone() Path

Clone will create new instance of the paths

func (*MemoryPath) Concat

func (m *MemoryPath) Concat(other Path) Path

Concat will concat the two paths together

func (*MemoryPath) Direct

func (m *MemoryPath) Direct() bool

Direct returns if the paths only has one element left

func (*MemoryPath) Drop

func (m *MemoryPath) Drop() Path

Drop will drop the last element in the path

func (*MemoryPath) ElementAt

func (m *MemoryPath) ElementAt(index int) Path

ElementAt returns the element of the paths at the given index starting at 0 If index is out of range, return an empty string

func (*MemoryPath) Equals

func (m *MemoryPath) Equals(path Path) bool

Equals returns if the path is equal to another

func (*MemoryPath) Pop

func (m *MemoryPath) Pop() Path

Pop will pop the first element in the paths

func (*MemoryPath) Size

func (m *MemoryPath) Size() int

Size returns the size of the paths

func (*MemoryPath) Slice

func (m *MemoryPath) Slice() []string

Slice returns the slice of path entries

func (*MemoryPath) String

func (m *MemoryPath) String() string

Returns the paths as a string

func (*MemoryPath) Valid

func (m *MemoryPath) Valid() bool

Valid returns if the path is actually valid

type Path

type Path interface {
	ElementAt(index int) Path
	Direct() bool
	Valid() bool
	Size() int

	Clone() Path
	Equals(path Path) bool

	Concat(other Path) Path
	Slice() []string
	String() string

	Pop() Path
	Drop() Path
}

Path represents a relative paths to a file

ElementAt returns the element of the paths at the given index starting at 0 If index is out of range, the returned path is not valid

Direct returns if the paths only has one element left

Valid returns if the path is actually valid

Size returns the amount of elements left in the paths

Clone will create new instance of the paths

Concat will concat the two paths together

Slice returns the slice of path entries

Pop will pop the first element in the paths

Drop drops the last element in the path

func RootPath

func RootPath() Path

RootPath returns a path with one single empty string entry

Jump to

Keyboard shortcuts

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