binpath

package module
v0.0.0-...-a567885 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2017 License: GPL-3.0 Imports: 2 Imported by: 3

README

binpath

A library providing tools for binary paths. Instead of delimiting path elements with a slash, they are simply length-prefixed. This way it is safe to store binary data inside.

My use case: I wanted to have paths in a key-value store, so I just use binpaths as keys.

Documentation

Overview

binpath is a package providing tools for binary paths

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Path

type Path []byte

Path is a path that may contain binary data

func FromBytes

func FromBytes(bs []byte) Path

FromBytes converts a byte slice to a path. Arguments should only contain a single path element.

func FromString

func FromString(sp string) (Path, error)

FromString converts a string to a path. Arguments should have the format "/home/keks/go", with the leading slash being optional. if an element in the path (i.e. "home" or "keks" in the example above) starts with "b:", the rest of the element is parsed as URL-compatible base64.

func Join

func Join(ps ...Path) Path

Join joins two paths and returns the result.

func Must

func Must(p Path, err error) Path

func (Path) Pop

func (p Path) Pop() (head Path, tail Path)

Pop splits the Path in two parts: the first element ("head") and the rest ("tail")

func (Path) String

func (p Path) String() string

String returns the path's string representation

Jump to

Keyboard shortcuts

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