Replace strings.Index usages with strings.Cut (#4930)

This commit is contained in:
WilczyńskiT 2022-08-04 19:17:35 +02:00 committed by GitHub
parent 17ae5acaba
commit 2642bd72b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 33 deletions

View file

@ -387,11 +387,11 @@ func parseEnvFile(envInput io.Reader) (map[string]string, error) {
}
// split line into key and value
fields := strings.SplitN(line, "=", 2)
if len(fields) != 2 {
before, after, isCut := strings.Cut(line, "=")
if !isCut {
return nil, fmt.Errorf("can't parse line %d; line should be in KEY=VALUE format", lineNumber)
}
key, val := fields[0], fields[1]
key, val := before, after
// sometimes keys are prefixed by "export " so file can be sourced in bash; ignore it here
key = strings.TrimPrefix(key, "export ")