patsy

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

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 9 Imported by: 2

README

Build Status Go Report Card codecov

Patsy

Patsy is a package helper for Go.

Dir

Dir returns the filesystem path for the directory corresponding to the go package path provided.

Path

Path returns the go package path corresponding to the filesystem directory provided.

Cache

NewCache returns a new *Cache, allowing cached access to patsy utility functions.

Documentation

Overview

package patsy is a package helper utility. It allows the conversion of go package paths to filesystem directories and vice versa.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(env vos.Env, packagePath string) (string, error)

Dir returns the filesystem path for the directory corresponding to the go package path provided.

func Dirs

func Dirs(env vos.Env, packagePath string) (map[string]string, error)

Dirs returns the filesystem path for all packages under the directory corresponding to the go package path provided.

func Name

func Name(env vos.Env, packagePath string, srcDir string) (string, error)

Name returns the package name for a given path and src dir. Note that the src dir (e.g. working dir) is required because multiple vendored packages can correspond to the same path when accessed from different dirs.

func Path

func Path(env vos.Env, packageDir string) (string, error)

Path returns the go package path corresponding to the filesystem directory provided.

Types

type Cache

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

Cache supports patsy.Dir and patsy.Path, but cached so they can be used in tight loops without hammering the filesystem.

func NewCache

func NewCache(env vos.Env) *Cache

NewCache returns a new *Cache, allowing cached access to patsy utility functions.

func (*Cache) Dir

func (c *Cache) Dir(ppath string) (string, error)

Dir does the same as patsy.Dir but cached.

func (*Cache) Dirs

func (c *Cache) Dirs(ppath string) (map[string]string, error)

Dirs does the same as patsy.Dirs but cached.

func (*Cache) FilePath

func (c *Cache) FilePath(gpath string) (string, error)

FilePath converts a package path and filename to a full filepath:

github.com/dave/foo.go -> /Users/dave/go/src/github.com/dave/foo.go

func (*Cache) GoName

func (c *Cache) GoName(fpath string) (string, error)

GoName converts a full filepath to a package path and filename:

/Users/dave/go/src/github.com/dave/foo.go -> github.com/dave/foo.go

func (*Cache) Name

func (c *Cache) Name(packagePath, srcDir string) (string, error)

Name does the same as patsy.Name but cached.

func (*Cache) Path

func (c *Cache) Path(dir string) (string, error)

Path does the same as patsy.Path but cached.

Directories

Path Synopsis
package builder can be used in testing to create a temporary go module or gopath, src, namespace and package directory, and populate it with source files.
package builder can be used in testing to create a temporary go module or gopath, src, namespace and package directory, and populate it with source files.
vos
Package vos is a virtual os tool.
Package vos is a virtual os tool.
os

Jump to

Keyboard shortcuts

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