Standard library / path
path.ErrBadPattern
Sentinel returned for malformed path.Match patterns; compare with errors.Is. Example uses a disposable temporary workspace. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrBadPattern errorWorking Example
Example Snippetgo
package main
import ( "errors" "fmt" "os" "path")
func check(e error) { if e != nil { panic(e) }}func workspace() func() { root, e := os.MkdirTemp("", "bytemind-go-") check(e) old, e := os.Getwd() check(e) check(os.Chdir(root)) return func() { check(os.Chdir(old)); check(os.RemoveAll(root)) }}func main() { defer workspace()() _, e := path.Match("[", "x") fmt.Println(errors.Is(e, path.ErrBadPattern))}