func matchWithSeparator(pattern, name string, separator rune) (bool, error) {
  patternComponents := splitPathOnSeparator(pattern, separator)
  nameComponents := splitPathOnSeparator(name, separator)
  return doMatching(patternComponents, nameComponents)
}
Match returns true if name matches the shell file name pattern.
The pattern syntax is:

pattern:
{ term }
term:
'*'         matches any sequence of non-path-separators
'**'        matches any sequence of characters, including
path separators.
'?'         matches any single non-path-separator character
'[' [ '^' ] { character-range } ']'
character class (must be non-empty)
'{' { term } [ ',' { term } ... ] '}'
c           matches character c (c != '*', '?', '\\', '[')
'\\' c      matches character c

character-range:
c           matches character c (c != '\\', '-', ']')
'\\' c      matches character c, unless separator is '\\'
lo '-' hi   matches character c for lo <= c <= hi

Match requires pattern to match all of name, not just a substring.
The only possible returned error is ErrBadPattern, when pattern
is malformed.
package doublestar
import (
  "path/filepath"
  "path"
  "os"
  "strings"
  "unicode/utf8"
  "fmt"
)
var ErrBadPattern = path.ErrBadPattern
func splitPathOnSeparator(path string, separator rune) []string {
  if separator == '\\' { return strings.Split(path, string(separator)) }
  cnt := strings.Count(path, string(separator))
  if cnt == 0 { return []string{path} }
  ret := make([]string, cnt + 1)
  pathlen := len(path)
  separatorLen := utf8.RuneLen(separator)
  idx := 0
  for start := 0; start < pathlen; {
    end := indexRuneWithEscaping(path[start:], separator)
    if end == -1 {
      end = pathlen
    } else {
      end += start
    }
    ret[idx] = path[start:end]
    start = end + separatorLen
    idx++
  }
  return ret[:idx]
}
func indexRuneWithEscaping(s string, r rune) int {
  end := strings.IndexRune(s, r)
  if end == -1 { return -1 }
  if end > 0 && s[end - 1] == '\\' {
    start := end + utf8.RuneLen(r)
    end = indexRuneWithEscaping(s[start:], r)
    if end != -1 { end += start }
  }
  return end
}
func Match(pattern, name string) (bool, error) {
  return matchWithSeparator(pattern, name, '/')
}
func PathMatch(pattern, name string) (bool, error) {
  return matchWithSeparator(pattern, name, os.PathSeparator)
}