gardenpath

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 5 Imported by: 0

README

/pkg/gardenpath

Purpose of /pkg/gardenpath:

  • To implment a common representation of file path.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEnvVarNotSet = fmt.Errorf("env var not set")

Functions

This section is empty.

Types

type GardenPath

type GardenPath []string

GardenPath is a smart path representation. It is a sequence of directory names starting from root directory.

The first element represents the root directory:

  • linux or else: empty string
  • windows: volume name (e.g. C:)

func New

func New(path string) (GardenPath, error)

New constructor handles:

  1. Clean dot and double dot
  2. tilde replacement,
  3. absolute path conversion,
  4. trailing slash removal.

It returns nil if the path is empty.

func NewCheckEnv

func NewCheckEnv(path string) (gp GardenPath, notFound []string, err error)

Returns a list of env vars that were not found.

func (GardenPath) Abs

func (p GardenPath) Abs() string

Get absolute path.

func (GardenPath) Copy

func (p GardenPath) Copy() GardenPath

func (GardenPath) IsEqual

func (p GardenPath) IsEqual(other GardenPath) bool

func (GardenPath) Last

func (p GardenPath) Last() string

Return the last element.

func (GardenPath) Parent

func (p GardenPath) Parent() GardenPath

Return the parent path. Technically it returns [0:len(p)-1].

Jump to

Keyboard shortcuts

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