github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/path/match.go (about) 1 // Copyright 2010 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package path 6 7 import ( 8 "github.com/shogo82148/std/errors" 9 ) 10 11 // ErrBadPatternは、パターンが不正であることを示します。 12 var ErrBadPattern = errors.New("syntax error in pattern") 13 14 // Matchはnameがシェルパターンと一致するかどうかを判定します。 15 // パターンの構文は以下のようになります: 16 // 17 // パターン: 18 // 19 // { 要素 } 20 // 21 // 要素: 22 // 23 // '*' 非/の任意のシーケンスに一致します 24 // '?' 非/の任意の1文字に一致します 25 // '[' [ '^' ] { 文字範囲 } ']' 26 // 文字のクラス(空でなければならない) 27 // c 文字cに一致します(c != '*', '?', '\\', '[') 28 // '\\' c 文字cに一致します 29 // 30 // 文字範囲: 31 // 32 // c 文字cに一致します(c != '\\', '-', ']') 33 // '\\' c 文字cに一致します 34 // lo '-' hi lo <= c <= hiの範囲の文字cに一致します 35 // 36 // Matchはパターンがname全体と一致する必要があります。部分一致ではありません。 37 // 返される可能性のある唯一のエラーは、patternが正しくない場合の [ErrBadPattern] です。 38 func Match(pattern, name string) (matched bool, err error)