Skip to content

Commit 58da188

Browse files
lint: if-else chain to switch
1 parent 25c1198 commit 58da188

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

interpreter/variable/field.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ func unsetField(subject, key, sep string) string {
5353
}
5454

5555
loc := re.FindStringIndex(subject)
56-
if len(loc) == 0 {
56+
switch {
57+
case len(loc) == 0:
5758
return subject
58-
} else if loc[0] == 0 { // found at the beginning of the header drop trailing separator
59+
case loc[0] == 0: // found at the beginning of the header drop trailing separator
5960
return subject[loc[1]:]
60-
} else if string(subject[loc[1]-1]) == sep { // found in the middle drop trailing separator
61+
case string(subject[loc[1]-1]) == sep: // found in the middle drop trailing separator
6162
return subject[:loc[0]] + subject[loc[1]-1:]
6263
}
6364
// found at the end drop leading separator

0 commit comments

Comments
 (0)