fs

package
v0.0.0-...-fd058c7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditFile

func EditFile(filePath string, f func(io.Reader, io.Writer) error) (retErr error)

EditFile edits the file using f and saves it.

func FileExists

func FileExists(filename string) bool

FileExists determines if path exists

func FindUp

func FindUp(start, path string) string

FindUp finds a path up the tree. On sucess, it returns found path, else "".

func Glob

func Glob(patterns []string) ([]*FileAsset, []*RegexpInfo, error)

Glob returns files and dirctories that match patterns. Patterns must use slashes, even Windows.

Special chars.

/**/   - match zero or more directories
{a,b}  - match a or b, no spaces
*      - match any non-separator char
?      - match a single non-separator char
**/    - match any directory, start of pattern only
/**    - match any this directory, end of pattern only
!      - removes files from resultset, start of pattern only

func Globexp

func Globexp(glob string) *regexp.Regexp

Globexp builds a regular express from from extended glob pattern and then returns a Regexp object.

func Load

func Load(src, dest string)

func Outdated

func Outdated(srcGlobs, destGlobs []string) bool

Outdated determines if ANY src has been modified after ANY dest.

For example: *.go.html -> *.go

If any go.html has changed then generate go files.

func PackageName

func PackageName(sourceFile string) (string, error)

PackageName determines the package name from sourceFile if it is within $GOPATH

func PartitionKV

func PartitionKV(r io.Reader, prefix string, assignment string) ([]map[string]string, error)

PartitionKV partitions a reader then parses key-value meta using an assignment string.

Example

PartitionKV(buf.NewBufferString(`

--@ key=SelectUser
SELECT * FROM users;

`, "--@", "=") => [{"_kind": "key", "key": "SelectUser", "_body": "SELECT * FROM users;"}]

func PatternRoot

func PatternRoot(s string) string

PatternRoot gets a real directory root from a pattern. The directory returned is used as the start location for globbing.

func ProgressBarConfig

func ProgressBarConfig(bar *pb.ProgressBar, prefix string)

func StrTemplate

func StrTemplate(src string, data map[string]interface{}) (string, error)

StrTemplate reads a go template and writes it to dist given data.

func StripPackageCommentsForFile

func StripPackageCommentsForFile(filePath string) error

StripPackageCommentsForFile strips the package comments for a file.

TODO(pedge): not real verification that we are in package comments, just takes the first block comment in the file and eliminates it.

func Template

func Template(src string, dest string, data map[string]interface{})

Template reads a go template and writes it to dist given data.

Types

type FileAsset

type FileAsset struct {
	os.FileInfo
	// Path to asset
	Path string
}

FileAsset contains file information and path from globbing.

func (*FileAsset) Stat

func (fa *FileAsset) Stat() (*os.FileInfo, error)

Stat updates the stat of this asset.

type ProgressBar

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

func (*ProgressBar) TrackProgress

func (cpb *ProgressBar) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser

type RegexpInfo

type RegexpInfo struct {
	Regexp *regexp.Regexp
	Negate bool
	Path   string
	Glob   string
}

RegexpInfo contains additional info about the Regexp created by a glob pattern.

func (*RegexpInfo) MatchString

func (ri *RegexpInfo) MatchString(s string) bool

MatchString matches a string with either a regexp or direct string match

type WatchCriteria

type WatchCriteria struct {
	Items []*WatchCriterion
}

WatchCriteria is the set of criterion to watch one or more glob patterns.

func EffectiveCriteria

func EffectiveCriteria(globs ...string) (*WatchCriteria, error)

EffectiveCriteria is the minimum set of criteria to watch the items in patterns

func (*WatchCriteria) Matches

func (cr *WatchCriteria) Matches(pth string) bool

Matches determines if pth is matched by internal criteria.

func (*WatchCriteria) Roots

func (cr *WatchCriteria) Roots() []string

Roots returns the root paths of all criteria.

type WatchCriterion

type WatchCriterion struct {
	// Root is the root directory to start watching.
	Root string
	// Includes are the regexp for including files
	IncludesRegexp []*regexp.Regexp
	// Excludes are the regexp for excluding files
	ExcludesRegexp []*regexp.Regexp
	Includes       []string
	Excludes       []string
}

WatchCriterion is the criteria needed to test if a file matches a pattern.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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