19 lines
351 B
Go
19 lines
351 B
Go
package tree
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
ignore "github.com/sabhiram/go-gitignore"
|
|
)
|
|
|
|
// Load 加载 .gitignore
|
|
func Load(root string) (*ignore.GitIgnore, error) {
|
|
path := filepath.Join(root, ".gitignore")
|
|
|
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
|
return ignore.CompileIgnoreLines(), nil
|
|
}
|
|
|
|
return ignore.CompileIgnoreFile(path)
|
|
} |