Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
aziule committed Jul 27, 2020
1 parent 27888b9 commit bc57203
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package foo

### Many-To-One match

Example: file ending with `_suffix.go` must include the `bar` build tag.
Example: files ending with `_suffix.go` must include the `bar` build tag.

File: `a_suffix.go`
```go
Expand Down Expand Up @@ -93,21 +93,54 @@ filebuildtag -filetags "*_integration_test.go:integration" .
filebuildtag -filetags "foo.go:bar,*_integration_test.go:integration" .
```

*Note: file name patterns match using Go's `filepath.Match` method and therefore support all of its features.*
*Note: file name patterns match using Go's `filepath.Match` method and therefore support all of its features.
See [File patterns](#file-patterns) for more information and examples.*

## Using with runners

To facilitate the integration with existing linter runners, you can use the `Analyzer` provided:
```go
cfg := filebuildtag.Config{}
cfg.WithFiletag("foo.go", "tag1").
.WithFiletag("*_suffix.go", "tag2")
WithFiletag("*_suffix.go", "tag2")
analyzer := NewAnalyzer(cfg)
```

## File patterns

### Syntax

From the official `filepath.Match` doc, file patterns syntax is the following:

```
pattern:
{ term }
term:
'*' matches any sequence of non-Separator characters
'?' matches any single non-Separator character
'[' [ '^' ] { character-range } ']'
character class (must be non-empty)
c matches character c (c != '*', '?', '\\', '[')
'\\' c matches character c
character-range:
c matches character c (c != '\\', '-', ']')
'\\' c matches character c
lo '-' hi matches character c for lo <= c <= hi
```

### Examples

| file 👇 pattern 👉 | foo.go | *.go | ba?.go |
|-----------|--------|------|--------|
| foo.go ||| 🚫 |
| bar.go | 🚫 |||
| baz.go | 🚫 |||
| something | 🚫 | 🚫 | 🚫 |

## Roadmap

* Support for folder name matching ("/pkg/**/foo.go", "/pkg/foo/*.go", etc.).
* Support for folder name matching (`/pkg/**/foo.go`, `/pkg/foo/*.go`, etc.).

## Contributing

Expand Down

0 comments on commit bc57203

Please sign in to comment.