code: func ParsePattern(p string, domain []string) Pattern {
  	res := pattern{domain: domain}
  
  	if strings.HasPrefix(p, inclusionPrefix) {
  		res.inclusion = true
  		p = p[1:]
  	}
  
  	if !strings.HasSuffix(p, "\\ ") {
  		p = strings.TrimRight(p, " ")
  	}
  
  	if strings.HasSuffix(p, patternDirSep) {
  		res.dirOnly = true
  		p = p[:len(p)-1]
  	}
  
  	if strings.Contains(p, patternDirSep) {
  		res.isGlob = true
  	}
  
  	res.pattern = strings.Split(p, patternDirSep)
  	return &res
  }
docs: // ParsePattern parses a gitignore pattern string into the Pattern structure.