go-path: github.com/ipfs/go-path Index | Files | Directories

package path

import "github.com/ipfs/go-path"

Package path contains utilities to work with ipfs paths.


Package Files

error.go path.go

func Join Uses

func Join(pths []string) string

Join joins strings slices using /

func SplitAbsPath Uses

func SplitAbsPath(fpath Path) (cid.Cid, []string, error)

SplitAbsPath clean up and split fpath. It extracts the first component (which must be a Multihash) and return it separately.

func SplitList Uses

func SplitList(pth string) []string

SplitList splits strings usings /

type Path Uses

type Path string

A Path represents an ipfs content path:

* /<cid>/path/to/file
* /ipfs/<cid>
* /ipns/<cid>/path/to/folder
* etc

func FromCid Uses

func FromCid(c cid.Cid) Path

FromCid safely converts a cid.Cid type to a Path type.

func FromSegments Uses

func FromSegments(prefix string, seg ...string) (Path, error)

FromSegments returns a path given its different segments.

func FromString Uses

func FromString(s string) Path

FromString safely converts a string type to a Path type.

func ParseCidToPath Uses

func ParseCidToPath(txt string) (Path, error)

ParseCidToPath takes a CID in string form and returns a valid ipfs Path.

func ParsePath Uses

func ParsePath(txt string) (Path, error)

ParsePath returns a well-formed ipfs Path. The returned path will always be prefixed with /ipfs/ or /ipns/. The prefix will be added if not present in the given string. This function will return an error when the given string is not a valid ipfs path.

func (Path) IsJustAKey Uses

func (p Path) IsJustAKey() bool

IsJustAKey returns true if the path is of the form <key> or /ipfs/<key>, or /ipld/<key>

func (*Path) IsValid Uses

func (p *Path) IsValid() error

IsValid checks if a path is a valid ipfs Path.

func (Path) PopLastSegment Uses

func (p Path) PopLastSegment() (Path, string, error)

PopLastSegment returns a new Path without its final segment, and the final segment, separately. If there is no more to pop (the path is just a key), the original path is returned.

func (Path) Segments Uses

func (p Path) Segments() []string

Segments returns the different elements of a path (elements are delimited by a /).

func (Path) String Uses

func (p Path) String() string

String converts a path to string.


resolverPackage resolver implements utilities for resolving paths within ipfs.

Package path imports 4 packages (graph) and is imported by 144 packages. Updated 2020-08-31. Refresh now. Tools for package owners.