mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
Replace strings.Index usages with strings.Cut (#4930)
This commit is contained in:
parent
17ae5acaba
commit
2642bd72b7
8 changed files with 32 additions and 33 deletions
|
@ -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 ")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue