1 Star 0 Fork 0

lonely / 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
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lonely0422/gometalinter.git
git@gitee.com:lonely0422/gometalinter.git
lonely0422
gometalinter
gometalinter
v2.0.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891