path

package module
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 4 Imported by: 184

README

go-path

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

Coverage Status Travis CI

❗ This repo is no longer maintained.

👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/path. 🏎️ Good news! There is tooling and documentation to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, here.

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.

License

MIT © Juan Batiz-Benet

Documentation

Overview

Package path contains utilities to work with ipfs paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join deprecated

func Join(pths []string) string

Join joins strings slices using /

Deprecated: use github.com/ipfs/boxo/path.Join

func SplitAbsPath deprecated

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.

Deprecated: use github.com/ipfs/boxo/path.SplitAbsPath

func SplitList deprecated

func SplitList(pth string) []string

SplitList splits strings usings /

Deprecated: use github.com/ipfs/boxo/path.SplitList

Types

type ErrInvalidPath deprecated added in v0.3.1

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

Deprecated: use github.com/ipfs/boxo/path.ErrInvalidPath

func (ErrInvalidPath) Error added in v0.3.1

func (e ErrInvalidPath) Error() string

func (ErrInvalidPath) Is added in v0.3.1

func (e ErrInvalidPath) Is(err error) bool

func (ErrInvalidPath) Unwrap added in v0.3.1

func (e ErrInvalidPath) Unwrap() error

type Path deprecated

type Path string

A Path represents an ipfs content path:

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

Deprecated: use github.com/ipfs/boxo/path.Path

func FromCid deprecated

func FromCid(c cid.Cid) Path

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

Deprecated: use github.com/ipfs/boxo/path.FromCid

func FromSegments deprecated

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

FromSegments returns a path given its different segments.

Deprecated: use github.com/ipfs/boxo/path.FromSegments

func FromString deprecated

func FromString(s string) Path

FromString safely converts a string type to a Path type.

Deprecated: use github.com/ipfs/boxo/path.FromString

func ParseCidToPath deprecated

func ParseCidToPath(txt string) (Path, error)

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

Deprecated: use github.com/ipfs/boxo/path.ParseCidToPath

func ParsePath deprecated

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.

Deprecated: use github.com/ipfs/boxo/path.ParsePath

func (Path) IsJustAKey

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

func (p *Path) IsValid() error

IsValid checks if a path is a valid ipfs 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 ipfs.
Package resolver implements utilities for resolving paths within ipfs.

Jump to

Keyboard shortcuts

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