ignore

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2021 License: MIT Imports: 6 Imported by: 0

README

ignore

parse .gitignore in go

解析 gitignore 格式文件然后进行匹配

usage:

import (
    "log"
    "strings"
    "gitee.com/go-wena/ignore"
)

func main(){
    //matcher, err := ignore.FromFile(".gitignore", ".")
    //if err != nil {
    //	log.Fatal(err)
    //}
    matcher := ignore.New(strings.NewReader("*.exe\n*.out\nbin/"), ".")
    log.Printf("./bin: %t\n", matcher.Match("./bin", true))
    log.Printf("./bin/file: %t\n", matcher.Match("./bin/file", false))
    log.Printf("./file.exe: %t\n", matcher.Match("./file.exe", false))
    log.Printf("./some: %t\n", matcher.Match("./some", false))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

func FromFile

func FromFile(ignoreFn string, dir string) (matcher *Matcher, err error)

func New

func New(r io.Reader, dir string) (matcher *Matcher)

func (*Matcher) Match

func (matcher *Matcher) Match(path string, isDir bool) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL