Skip to content

Commit

Permalink
README adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed May 2, 2020
1 parent 6611e8e commit 1a01b95
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# doublestar

Path pattern matching and globbing supporting `doublestar` (`**`) patterns.

![Release](https://img.shields.io/github/release/bmatcuk/doublestar.svg?branch=master)
[![Build Status](https://travis-ci.org/bmatcuk/doublestar.svg?branch=master)](https://travis-ci.org/bmatcuk/doublestar)
[![codecov.io](https://img.shields.io/codecov/c/github/bmatcuk/doublestar.svg?branch=master)](https://codecov.io/github/bmatcuk/doublestar?branch=master)

# doublestar
## About

**doublestar** is a [golang](http://golang.org/) implementation of path pattern
matching and globbing with support for "doublestar" (aka globstar: `**`)
Expand All @@ -11,7 +15,7 @@ patterns.
doublestar patterns match files and directories recursively. For example, if
you had the following directory structure:

```
```bash
grandparent
`-- parent
|-- child1
Expand Down Expand Up @@ -43,9 +47,10 @@ To use it in your code, you must import it:
import "github.com/bmatcuk/doublestar"
```

## Functions
## Usage

### Match

```go
func Match(pattern, name string) (bool, error)
```
Expand All @@ -61,18 +66,20 @@ want to use `PathMatch()` (below) instead.


### PathMatch

```go
func PathMatch(pattern, name string) (bool, error)
```

PathMatch returns true if `name` matches the file name `pattern`
PathMatch returns true if `name` matches the file name `pattern`
([see below](#patterns)). The difference between Match and PathMatch is that
PathMatch will automatically use your system's path separator to split `name`
and `pattern`.

`PathMatch()` is meant to be a drop-in replacement for `filepath.Match()`.

### Glob

```go
func Glob(pattern string) ([]string, error)
```
Expand All @@ -83,7 +90,7 @@ directory), or absolute.

`Glob()` is meant to be a drop-in replacement for `filepath.Glob()`.

## Patterns
### Patterns

**doublestar** supports the following special terms in the patterns:

Expand All @@ -97,7 +104,7 @@ Special Terms | Meaning
Any character with a special meaning can be escaped with a backslash (`\`).
### Character Classes
#### Character Classes
Character classes support the following:
Expand All @@ -107,7 +114,7 @@ Class | Meaning
`[a-z]` | matches any single character in the range
`[^class]` | matches any single character which does *not* match the class
## Abstracting the `os` package
### Abstracting the `os` package
**doublestar** by default uses the `Open`, `Stat`, and `Lstat`, functions and
`PathSeparator` value from the standard library's `os` package. To abstract
Expand All @@ -118,12 +125,16 @@ operate on an `OS` interface:
```go
type OS interface {
Lstat(name string) (os.FileInfo, error)
Open(name string) (*os.File, error)
PathSeparator() rune
Stat(name string) (os.FileInfo, error)
Lstat(name string) (os.FileInfo, error)
Open(name string) (*os.File, error)
PathSeparator() rune
Stat(name string) (os.FileInfo, error)
}
```

`StandardOS` is a value that implements this interface by calling functions in
the standard library's `os` package.
the standard library's `os` package.

## License

[MIT License](LICENSE)

0 comments on commit 1a01b95

Please sign in to comment.