Giter Site home page Giter Site logo

sif's Introduction

SIF

Build Status Go Report Card codecov

Search In Files
An experimental ack 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

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

package main

import (
	"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)
		}
	}
}

sif's People

Contributors

drgarcia1986 avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.