Git Product home page Git Product logo

nogo's Introduction

NoGo test CodeQL

A .gitignore parser for Go.

Features

  • parsing .gitignore files
  • loading file trees with several .gitignore files
  • fs.WalkDir WalkDirFunc implementation (and afero.Walk (see below))
  • customizable ignore filename (instead of .gitignore)
  • full compatibility with git
    As far as I could test it, it handles .gitignore files the same way as git.
    If you find an inconsistency with git, please create a new Issue.
    The goal is to provide the exact same .gitignore handling.

Stability

Note that this lib is currently beta and therefore may introduce breaking changes. However I don't think much will change.

Usage

n := nogo.New(nogo.DotGitRule)
if err := n.AddFromFS(wdfs, ".gitignore"); err != nil {
    panic(err)
}

match := n.Match(toSearch, isDir)
fmt.Println(match)

There is also an alternative MatchBecause method which returns also the causing rule if you need some context.

There exists a predefined rule to ignore any .git folder automatically.

n := nogo.New(nogo.DotGitRule)
if err := n.AddFromFS(wdfs, ".gitignore"); err != nil {
    panic(err)
}

Walk

NoGo can be used with fs.WalkDir. Just see the example walk. If you need to use another Walk function, you can build your own wrapper using the NoGo.WalkFunc function.

I intentionally did not include an afero walk to avoid a new dependency just because of afero-compatibility. However, you can easily build your own.
You can find an example for afero in the documentation of NoGo.WalkFunc.

nogo's People

Contributors

aligator avatar dependabot[bot] 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.