expand

package
Version: v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const BasePrefix = "//"

Variables

View Source
var (
	// ErrNoPrefix gets returned if the given path does not have a prefix.
	ErrNoPrefix = fmt.Errorf("path does not have a prefix")
)

Functions

func Expand

func Expand(base, fp string) string

Expand expands paths with leading //-prefix with the default project path.

func ExpandFilepath

func ExpandFilepath(base, fp string) string

ExpandFilepath expands paths with leading //-prefix with the default project path.

func HasPrefix

func HasPrefix(path string) bool

IsProjectPathPresent says whether the given path is expandable.

Types

type BaseExpander

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

BaseExpander expands based on the given base.

func Base

func Base(path string) *BaseExpander

Base creates a new BaseExpander.

func (*BaseExpander) Base

func (b *BaseExpander) Base() string

Base returns the base path BaseExpander adds.

func (*BaseExpander) Expand

func (b *BaseExpander) Expand(path string) string

Expand replaces BasePrefix at the front with the stored base path.

func (*BaseExpander) ExpandFilepath

func (b *BaseExpander) ExpandFilepath(path string) string

ExpandFilepath replaces BasePrefix at the front with the stored base filepath.

type Expander

type Expander interface {
	Expand(path string) string
	ExpandFilepath(path string) string
}

Expander is an interface for components which are able to expand path prefixes to absolute paths.

Jump to

Keyboard shortcuts

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