Skip to content

fix: stringify *string values in toString - #487

Open
sb123sb123 wants to merge 1 commit into
Masterminds:masterfrom
sb123sb123:fix/strval-pointer-439
Open

sb123sb123 wants to merge 1 commit into
Masterminds:masterfrom
sb123sb123:fix/strval-pointer-439

Conversation

@sb123sb123

@sb123sb123 sb123sb123 commented Sep 21, 2026 •

Copy link
Copy Markdown

Summary

toString currently formats *string values with fmt.Sprintf("%v", v), exposing the pointer address; a nil *string is rendered as <nil>. Handle *string explicitly so the referenced value is returned, with an empty string for nil pointers.

Fixes #439

Changes

  • Add *string handling to strval.
  • Add regression coverage for non-nil and nil *string values.

Testing

  • go test ./... -run "TestToStringPointers|TestToString" -count=1 � pass

  • go vet ./... � pass

  • gofmt -w strings.go strings_test.go and git diff --check � pass

  • go test ./... -count=1 � the existing TestHtmlDate fails on this Windows runner (2019-06-14 received vs 2019-06-13 expected); the same failure was reproduced with the implementation reverted, so it is unrelated.

  • go test -cover . -count=1 � same pre-existing TestHtmlDate failure; coverage reached 84.4%.

  • proxy.golang.org was unreachable from the runner, so dependencies were fetched through https://goproxy.cn,direct; no dependency files changed.

  • Local validation used the available G-drive Go 1.26.7 toolchain; repository CI remains the coverage for its Go 1.22-1.24 matrix.

AI assistance

This change was prepared with AI assistance from Codex. The implementation, regression test, complete diff, signature, and test results were reviewed before submission.

This branch has not been deployed

No deployments
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.

toString should handle *string

1 participant