path

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 4 Imported by: 14

README

go-path

Coverage Status Travis CI

go-path is a helper package that provides utilities for parsing and using ipfs paths

Lead Maintainer

Steven Allen

Table of Contents

TODO

This package could probably be merged into go-ipld, or something along those lines. It doesnt really make sense as its own standalone thing.

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Juan Batiz-Benet

Documentation

Overview

Package path contains utilities to work with dms3 paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(pths []string) string

Join joins strings slices using /

func SplitAbsPath

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

func SplitList(pth string) []string

SplitList splits strings usings /

Types

type Path

type Path string

A Path represents an dms3 content path:

  • /<cid>/path/to/file
  • /dms3/<cid>
  • /dms3ns/<cid>/path/to/folder
  • etc

func FromCid

func FromCid(c cid.Cid) Path

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

func FromSegments

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

FromSegments returns a path given its different segments.

func FromString

func FromString(s string) Path

FromString safely converts a string type to a Path type.

func ParseCidToPath

func ParseCidToPath(txt string) (Path, error)

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

func ParsePath

func ParsePath(txt string) (Path, error)

ParsePath returns a well-formed dms3 Path. The returned path will always be prefixed with /dms3/ or /dms3ns/. 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 dms3 path.

func (Path) IsJustAKey

func (p Path) IsJustAKey() bool

IsJustAKey returns true if the path is of the form <key> or /dms3/<key>, or /ld/<key>

func (*Path) IsValid

func (p *Path) IsValid() error

IsValid checks if a path is a valid dms3 Path.

func (Path) PopLastSegment

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

func (p Path) Segments() []string

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

func (Path) String

func (p Path) String() string

String converts a path to string.

Directories

Path Synopsis
Package resolver implements utilities for resolving paths within dms3.
Package resolver implements utilities for resolving paths within dms3.

Jump to

Keyboard shortcuts

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