code: func scanChunk(pattern string) (star bool, chunk, rest string) {
  	for len(pattern) > 0 && pattern[0] == '*' {
  		pattern = pattern[1:]
  		star = true
  	}
  	inrange := false
  	var i int
  Scan:
  	for i = 0; i < len(pattern); i++ {
  		switch pattern[i] {
  		case '\\':
  			if runtime.GOOS != "windows" {
  				// error check handled in matchChunk: bad pattern.
  				if i+1 < len(pattern) {
  					i++
  				}
  			}
  		case '[':
  			inrange = true
  		case ']':
  			inrange = false
  		case '*':
  			if !inrange {
  				break Scan
  			}
  		}
  	}
  	return star, pattern[0:i], pattern[i:]
  }
docs: // scanChunk gets the next segment of pattern, which is a non-star string
  // possibly preceded by a star.