https://github.com/drgarcia1986/sif
A minimal (and experimental) ACK written in Go
https://github.com/drgarcia1986/sif
ack ag go
Last synced: 6 months ago
JSON representation
A minimal (and experimental) ACK written in Go
- Host: GitHub
- URL: https://github.com/drgarcia1986/sif
- Owner: drgarcia1986
- License: mit
- Created: 2017-01-31T02:55:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-13T16:30:15.000Z (over 8 years ago)
- Last Synced: 2024-07-30T10:19:21.956Z (about 1 year ago)
- Topics: ack, ag, go
- Language: Go
- Homepage:
- Size: 577 KB
- Stars: 19
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SIF
[](https://travis-ci.org/drgarcia1986/sif)
[](https://goreportcard.com/report/drgarcia1986/sif)
[](https://codecov.io/gh/drgarcia1986/sif)**S**earch **I**n **F**iles
An experimental [ack](https://github.com/petdance/ack2) written in Go.## Installation
If you have a Golang environment setup, you can simply run:
```
$ go get -u github.com/drgarcia1986/sif/cmd/sif
```
Or get binaries on [releases](https://github.com/drgarcia1986/sif/releases)> For windows users: Colors works only in PowerShell
## Example
Run against repo dir:
```
$ sif better
_tests/golang.txt
9: A little copying is better than a little dependency.
14: Clear is better than clever._tests/python.txt
3: Beautiful is better than ugly.
4: Explicit is better than implicit.
5: Simple is better than complex.
6: Complex is better than complicated.
7: Flat is better than nested.
8: Sparse is better than dense.
17: Now is better than never.
18: Although never is often better than *right* now.sif_test.go
14: {"python.txt", "better", []int{3, 4, 5, 6, 7, 8, 17, 18}},
```
Same search with `ack`, `grep` and `sif`, time comparison:
```
$ time ack better
...
0.11 real 0.07 user 0.01 sys
```
```
$ time grep better -rn *
...
0.04 real 0.03 user 0.00 sys
```
```
$ time sif better
...
0.01 real 0.00 user 0.00 sys
```## Library Usage Example
```go
package mainimport (
"fmt""github.com/drgarcia1986/sif"
)func main() {
s, _ := sif.New("fmt", sif.Options{CaseInsensitive: false})
fm, err := s.ScanFile("./main.go")
if err != nil {
panic(err)
}
if fm != nil {
for _, m := range fm.Matches {
fmt.Printf("Line: %d, Text: %s\n", m.Line, m.Text)
}
}
}
```