Skip to content

fix(key): check element instead of slice length in StringsWithShadows - #387

Open
AruneshDwivedi wants to merge 1 commit into
go-ini:mainfrom
AruneshDwivedi:main
Open

fix(key): check element instead of slice length in StringsWithShadows#387
AruneshDwivedi wants to merge 1 commit into
go-ini:mainfrom
AruneshDwivedi:main

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

StringsWithShadows used len(vals) == 0 inside a for-range loop over vals, which is always false when the loop body executes. This check was intended to skip empty element values but instead checked the entire slice length (dead code pattern).

Empty string values were passed through to strings.Split and produced spurious blank entries in results. Changed to iterate with for _, v := range vals and check if v == "" to properly skip individual empty values.

StringsWithShadows used "len(vals) == 0" inside a for-range loop over vals,
which is always false when the loop body executes (the loop never runs on empty
slices). This meant empty string values were passed through to strings.Split
and produced spurious blank entries in results.

Changed to iterate with "for _, v := range vals" and check "if v == \"\""
to properly skip individual empty values.

Signed-off-by: Kushal Dwivedi <arunesh.devops@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant