funcMatch(pattern, name string)(matched bool, err error)
通配符匹配,规则
1 2 3 4 5 6 7 8 9 10 11 12 13 14
pattern: { term } term: '*' matches any sequence of non-/ characters '?' matches any single non-/ character '[' [ '^' ] { character-range } ']' character class (must be non-empty) c matches character c (c != '*', '?', '\\', '[') '\\' c matches character c
character-range: c matches character c (c != '\\', '-', ']') '\\' c matches character c lo '-' hi matches character c for lo <= c <= hi
fmt.Println("On Unix:") for _, p := range paths { rel, err := filepath.Rel(base, p) fmt.Printf("%q: %q %v\n", p, rel, err) }
}
1 2 3 4
On Unix: "/a/b/c": "b/c" <nil> "/b/c": "../b/c" <nil> "./b/c": "" Rel: can't make ./b/c relative to /a
func VolumeName
1
funcVolumeName(path string)string
VolumeName returns leading volume name. Given “C:\foo\bar” it returns “C:” on Windows. Given “\host\share\foo” it returns “\host\share”. On other platforms it returns “”.