summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorChirag Maheshwari <34106488+chir4gm@users.noreply.github.com>2022-08-07 09:33:37 +0530
committerGitHub <noreply@github.com>2022-08-06 22:03:37 -0600
commitd26559316fa6fae880351637365f07947a2b79f6 (patch)
tree1da2ac269d13f48b30d0232f4e28069c02fc9e87 /cmd
parent2642bd72b7ca35b8622824fdffced2aefe1aaf11 (diff)
Replace strings.Index with strings.Cut (#4932)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/main.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/cmd/main.go b/cmd/main.go
index c475eaa..09246f4 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -408,11 +408,8 @@ func parseEnvFile(envInput io.Reader) (map[string]string, error) {
}
// remove any trailing comment after value
- if commentStart := strings.Index(val, "#"); commentStart > 0 {
- before := val[commentStart-1]
- if before == '\t' || before == ' ' {
- val = strings.TrimRight(val[:commentStart], " \t")
- }
+ if commentStart, _, found := strings.Cut(val, "#"); found {
+ val = strings.TrimRight(commentStart, " \t")
}
// quoted value: support newlines