package main import ( "os" "path/filepath" ignore "github.com/sabhiram/go-gitignore" ) func loadGitignore(hostDir string) (*ignore.GitIgnore, error) { gitignorePath := filepath.Join(hostDir, ".gitignore") if _, err := os.Stat(gitignorePath); os.IsNotExist(err) { return ignore.CompileIgnoreLines(), nil } return ignore.CompileIgnoreFile(gitignorePath) }