Skip to content

Split string pointers into fields in ToStringSliceE - #376

Open
Twiink wants to merge 2 commits into
spf13:masterfrom
Twiink:fix/split-string-pointer-fields
Open

Twiink wants to merge 2 commits into
spf13:masterfrom
Twiink:fix/split-string-pointer-fields

Conversation

@Twiink

@Twiink Twiink commented Nov 18, 2026

Copy link
Copy Markdown

A multi-word string passed to ToStringSliceE is split with strings.Fields, but passing a pointer to the same string returns a single element containing the entire string. This changes the result when a configuration binding supplies a pointer. Detect string inputs on the dereferenced value while preserving the original scalar value for conversions that use its methods.

The shared value/pointer test matrix reproduces the discrepancy with spaces and a tab. go test ./... and go vet ./... pass.

@CLAassistant

CLAassistant commented Nov 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Ekko82 Ekko82 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran four focused API cases on Windows x64 with Go 1.27.1. The *string case now splits on spaces and tabs, and the plain string case passed on both revisions. The two scalar cases below failed on this head. I ran these cases outside the full suite.

Comment thread slice.go Resolved

@Ekko82 Ekko82 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reran the four focused API cases from the previous review on 2b69164. Both pointer-method cases now return a one-element slice containing "alpha beta" with no error. The *string case still splits on spaces and tabs, and the plain-string control still passes. All four passed on Windows x64 with Go 1.27.1. I ran these outside the full suite.

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.

3 participants