File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ func PathNoExt(fPath string) string {
3030
3131// Name get file/dir name from full path.
3232//
33- // eg: path/to/main.go => "main.go"
33+ // eg:
34+ // "path/to/main.go" => "main.go"
35+ // "/foo/bar/baz" => "baz"
3436func Name (fPath string ) string {
3537 if fPath == "" {
3638 return ""
Original file line number Diff line number Diff line change @@ -116,6 +116,16 @@ func IContains(s, sub string) bool {
116116// ContainsByte in given string.
117117func ContainsByte (s string , c byte ) bool { return strings .IndexByte (s , c ) >= 0 }
118118
119+ // ContainsByteOne in given string.
120+ func ContainsByteOne (s string , bs []byte ) bool {
121+ for _ , b := range bs {
122+ if strings .IndexByte (s , b ) >= 0 {
123+ return true
124+ }
125+ }
126+ return false
127+ }
128+
119129// InArray alias of HasOneSub()
120130var InArray = HasOneSub
121131
Original file line number Diff line number Diff line change @@ -233,6 +233,10 @@ func TestIContains(t *testing.T) {
233233
234234 assert .True (t , strutil .ContainsByte ("H3AB2C" , 'A' ))
235235 assert .False (t , strutil .ContainsByte ("H3AB2C" , 'a' ))
236+
237+ assert .True (t , strutil .ContainsByteOne ("H3AB2C" , []byte ("A" )))
238+ assert .True (t , strutil .ContainsByteOne ("H3AB2C" , []byte ("DB" )))
239+ assert .False (t , strutil .ContainsByteOne ("H3AB2C" , []byte ("D" )))
236240}
237241
238242func TestHasOneSub (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments