Source File
match.go
Belonging Package
path
package path
import (
)
var ErrBadPattern = errors.New("syntax error in pattern")
return bytealg.IndexByteString(, '/') < 0, nil
for := 0; < len() && [] != '/'; ++ {
, , := matchChunk(, [+1:])
var rune
if ! {
var int
, = utf8.DecodeRuneInString()
= [:]
}
:= false
:= 0
for {
if len() > 0 && [0] == ']' && > 0 {
= [1:]
break
}
var , rune
if , , = getEsc(); != nil {
return "", false,
}
=
if [0] == '-' {
if , , = getEsc([1:]); != nil {
return "", false,
}
}
if <= && <= {
= true
}
++
}
if == {
= true
}
case '?':
if ! {
if [0] == '/' {
= true
}
, := utf8.DecodeRuneInString()
= [:]
}
= [1:]
case '\\':
= [1:]
if len() == 0 {
return "", false, ErrBadPattern
}
fallthrough
default:
if ! {
if [0] != [0] {
= true
}
= [1:]
}
= [1:]
}
}
if {
return "", false, nil
}
return , true, nil
}
func ( string) ( rune, string, error) {
if len() == 0 || [0] == '-' || [0] == ']' {
= ErrBadPattern
return
}
if [0] == '\\' {
= [1:]
if len() == 0 {
= ErrBadPattern
return
}
}
, := utf8.DecodeRuneInString()
if == utf8.RuneError && == 1 {
= ErrBadPattern
}
= [:]
if len() == 0 {
= ErrBadPattern
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |