瀏覽代碼

all: use strings.Contains instead Index

Signed-off-by: Elena Morozova <lelenanam@gmail.com>
Elena Morozova 8 年之前
父節點
當前提交
a37027f6bd
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      pkg/fileutils/fileutils.go
  2. 1 1
      runconfig/opts/parse.go

+ 1 - 1
pkg/fileutils/fileutils.go

@@ -180,7 +180,7 @@ func regexpMatch(pattern, path string) (bool, error) {
 		} else if ch == '?' {
 		} else if ch == '?' {
 			// "?" is any char except "/"
 			// "?" is any char except "/"
 			regStr += "[^" + escSL + "]"
 			regStr += "[^" + escSL + "]"
-		} else if strings.Index(".$", string(ch)) != -1 {
+		} else if ch == '.' || ch == '$' {
 			// Escape some regexp special chars that have no meaning
 			// Escape some regexp special chars that have no meaning
 			// in golang's filepath.Match
 			// in golang's filepath.Match
 			regStr += `\` + string(ch)
 			regStr += `\` + string(ch)

+ 1 - 1
runconfig/opts/parse.go

@@ -697,7 +697,7 @@ func parseSecurityOpts(securityOpts []string) ([]string, error) {
 	for key, opt := range securityOpts {
 	for key, opt := range securityOpts {
 		con := strings.SplitN(opt, "=", 2)
 		con := strings.SplitN(opt, "=", 2)
 		if len(con) == 1 && con[0] != "no-new-privileges" {
 		if len(con) == 1 && con[0] != "no-new-privileges" {
-			if strings.Index(opt, ":") != -1 {
+			if strings.Contains(opt, ":") {
 				con = strings.SplitN(opt, ":", 2)
 				con = strings.SplitN(opt, ":", 2)
 			} else {
 			} else {
 				return securityOpts, fmt.Errorf("Invalid --security-opt: %q", opt)
 				return securityOpts, fmt.Errorf("Invalid --security-opt: %q", opt)