fs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package fs provides filesystem related utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir

func Chdir(v *nvim.Nvim, dir string) func()

Chdir changes the vim current working directory. The returned function restores working directory to `getcwd()` result path and unlocks the mutex.

func Create

func Create(filename string) error

func ExpandGoRoot

func ExpandGoRoot(p string) string

ExpandGoRoot expands the "$GOROOT" include from p.

func FindAllPackage

func FindAllPackage(root string, buildContext build.Context, ignores []string, mode FindMode) ([]*build.Package, error)

FindAllPackage returns a list of all packages in all of the GOPATH trees in the given build context. If prefix is non-empty, only packages whose import paths begin with prefix are returned.

func FindVCSRoot

func FindVCSRoot(path string) string

FindVCSRoot finds the vcs root directory from path.

func GbFindProjectRoot

func GbFindProjectRoot(path string) (string, error)

GbFindProjectRoot works upwards from path seaching for the src/ directory which identifies the project root. Code taken directly from constabulary/gb.

github.com/constabulary/gb/cmd/path.go

func GbPackages

func GbPackages(root string) ([]string, error)

GbPackages return the gb packages.

func GbProjectName

func GbProjectName(projectRoot string) string

GbProjectName return the gb project name.

func IsDir

func IsDir(filename string) bool

IsDir returns whether the filename is directory.

func IsDirExist

func IsDirExist(dir string) bool

IsDirExist reports whether dir exists and which is directory.

func IsExist

func IsExist(filename string) bool

IsExist returns whether the filename is exists.

func IsGb

func IsGb(dir string) (string, bool)

IsGb check the current buffer directory whether gb directory structure. Return the gb project root path and boolean, and sets the context.GbProjectDir.

func IsGoFile

func IsGoFile(filename string) bool

IsGoFile returns whether the filename is exists.

func IsNotExist

func IsNotExist(filename string) bool

IsNotExist returns whether the filename is exists.

func JoinGoPath

func JoinGoPath(p string) string

JoinGoPath joins the $GOPATH + "src" to p

func Mkdir

func Mkdir(dir string, perm os.FileMode) error

func PackageID

func PackageID(dir string) (string, error)

PackageID returns the package ID(ImportPath) estimated from the dir directory structure. like:

return "github.com/pkg/errors", nil

func PackagePath

func PackagePath(dir string) (string, error)

PackagePath returns the *full path* of package directory estimated from the dir directory structure. like:

return "/Users/zchee/go/src/github.com/pkg/errors", nil

func PackageRoot

func PackageRoot(path string) (*build.Package, error)

PackageRoot finds repository root of package from path. Return the '/root' if path is '/root/foo/bar'. If path package directory archtecture uses '/root/src/foo', returns the '/root/src'.

func Rel

func Rel(cwd, f string) string

Rel wrapper of filepath.Rel function that return only one variable.

func ShortFilePath

func ShortFilePath(p, cwd string) string

ShortFilePath return the simply trim cwd into p.

func ToGoPath

func ToGoPath(p string) string

ToGoPath trims the GOPATH and {bin,pkg,src}, basically for the converts the package ID.

func ToWildcard

func ToWildcard(path string) string

ToWildcard returns the path with wildcard(...) suffix.

func TrimGoPath

func TrimGoPath(p string) string

TrimGoPath trims the GOPATH and {bin,pkg,src}, basically for the converts the package ID

func VendorPath

func VendorPath(p string) string

VendorPath finds the package root and returens the vendor directory path.

Types

type FindMode

type FindMode int
const (
	ModeExcludeVendor FindMode = 1 << iota
)

Jump to

Keyboard shortcuts

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