1 Star 0 Fork 0

goproxies / github.com-alecthomas-gometalinter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
parse.go 700 Bytes
一键复制 编辑 原始数据 按行查看 历史
Alec Thomas 提交于 2017-07-12 15:41 . Update all vendored linters.
package ignore
import (
"bytes"
)
// Parse reads in a gitignore file and returns a Matcher
func Parse(src []byte) (Matcher, error) {
matchers := []Matcher{}
lines := bytes.Split(src, []byte{'\n'})
for _, line := range lines {
if len(line) == 0 || len(bytes.TrimSpace(line)) == 0 {
continue
}
if line[0] == '#' {
continue
}
// TODO: line starts with '!'
// TODO: line ends with '\ '
// if starts with \# or \! then escaped
if len(line) > 1 && line[0] == '\\' && (line[1] == '#' || line[1] == '!') {
line = line[1:]
}
m, err := NewGlobMatch(line)
if err != nil {
return nil, err
}
matchers = append(matchers, m)
}
return NewMultiMatch(matchers), nil
}
1
https://gitee.com/goproxies/github.com-alecthomas-gometalinter.git
git@gitee.com:goproxies/github.com-alecthomas-gometalinter.git
goproxies
github.com-alecthomas-gometalinter
github.com-alecthomas-gometalinter
v3.0.0

搜索帮助