paths

package
v1.41.4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidModPath

func ValidModPath(p string) bool

ValidModPath reports whether a given module path is valid.

func ValidPkgPath

func ValidPkgPath(p string) bool

ValidPkgPath reports whether a given module path is valid.

Types

type FS

type FS string

FS represents a filesystem path.

It is an absolute path, and is always in the OS-specific format.

func RootedFSPath

func RootedFSPath(wd, p string) FS

RootedFSPath returns a new FS path. It should typically not be used except for at parser initialization. Use FS.Join, FS.New, or FS.Resolve instead to preserve the working dir.

func (FS) Base

func (fs FS) Base() string

Base returns the filepath.Base of the path.

func (FS) Dir

func (fs FS) Dir() FS

Dir returns the filepath.Dir of the path.

func (FS) HasPrefix

func (fs FS) HasPrefix(other FS) bool

HasPrefix reports whether fs is a descendant of other or is equal to other. (i.e. it is the given path or a subdirectory of it)

func (FS) Join

func (fs FS) Join(elem ...string) FS

Join joins the path with the given elems, according to filepath.Join.

func (FS) JoinSlash added in v1.35.3

func (fs FS) JoinSlash(rel RelSlash) FS

func (FS) Resolve

func (fs FS) Resolve(p string) FS

Resolve returns a new FS path to the given path. If p is absolute it returns p directly, otherwise it returns the path joined with the current path.

func (FS) ToDisplay

func (fs FS) ToDisplay() string

ToDisplay returns the path in a form suitable for displaying to the user.

func (FS) ToIO

func (fs FS) ToIO() string

ToIO returns the path for use in IO operations.

type FileReader added in v1.35.3

type FileReader func(string) ([]byte, error)

type MainModuleRelSlash added in v1.16.3

type MainModuleRelSlash string

MainModuleRelSlash is like RelSlash, but it's always relative to the application's main module directory.

func (MainModuleRelSlash) String added in v1.16.3

func (p MainModuleRelSlash) String() string

func (MainModuleRelSlash) ToIO added in v1.16.3

func (p MainModuleRelSlash) ToIO(mainModDir FS) string

ToIO converts the slash-separated path to a filesystem path using filepath.FromSlash.

type Mod

type Mod string

Mod represents a module path. It is always slash-separated.

func MustModPath

func MustModPath(p string) Mod

MustModPath returns a new Mod path for p.

func StdlibMod

func StdlibMod() Mod

StdlibMod returns the Mod path representing the standard library.

func (Mod) IsStdlib

func (m Mod) IsStdlib() bool

IsStdlib reports whether m represents the standard library.

func (Mod) LexicallyContains

func (m Mod) LexicallyContains(p Pkg) bool

LexicallyContains reports whether the given module path contains the package path p. It only considers the lexical path and ignores whether there exists a nested module that contains p.

func (Mod) Pkg added in v1.35.3

func (m Mod) Pkg(rel RelSlash) Pkg

func (Mod) RelativePathToPkg

func (m Mod) RelativePathToPkg(p Pkg) (relative RelSlash, ok bool)

RelativePathToPkg returns the relative path from the module to the package. If the package is not contained within the module it reports "", false.

type Pkg

type Pkg string

Pkg represents a package path within a module. It is always slash-separated.

func MustPkgPath

func MustPkgPath(p string) Pkg

func PkgPath

func PkgPath(p string) (Pkg, bool)

PkgPath returns a new Pkg path for p. If p is not a valid package path it reports "", false.

func (Pkg) JoinSlash

func (p Pkg) JoinSlash(elem ...RelSlash) Pkg

JoinSlash joins the path with the given elems, according to path.Join. The elems are expected to be slash-separated, not filesystem-separated. Use filesystem.ToSlash() to convert filesystem paths to slash-separated paths.

func (Pkg) LexicallyContains

func (p Pkg) LexicallyContains(other Pkg) bool

LexicallyContains reports whether the given package path contains the package path p as a "sub-package".

func (Pkg) String

func (p Pkg) String() string

String returns the string representation of p.

type RelSlash

type RelSlash string

RelSlash is a relative path that is always slash-separated.

func (RelSlash) Join added in v1.35.3

func (rel RelSlash) Join(elem ...string) RelSlash

Join joins the path with the given elems, according to path.Join.

func (RelSlash) String

func (p RelSlash) String() string

func (RelSlash) ToIO

func (p RelSlash) ToIO() string

ToIO converts the slash-separated path to a filesystem path using filepath.FromSlash.

Jump to

Keyboard shortcuts

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