Skip to content

docs: clarify Standardize input ownership - #58

Open
jihtsan wants to merge 1 commit into
tailscale:masterfrom
jihtsan:codex/57-document-standardize-input
Open

jihtsan wants to merge 1 commit into
tailscale:masterfrom
jihtsan:codex/57-document-standardize-input

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 16, 2026

Copy link
Copy Markdown

Standardize parses slices backed by the caller's input and overwrites comment bytes before packing the result. Callers that retain their original JSONC buffer can therefore lose its comments.

Document that the input may be modified and show Standardize(bytes.Clone(b)) for callers that need to preserve it. This follows the documentation option in #57 and the existing CLI's practice of copying its source buffer; runtime behavior and allocation costs stay the same.

Validation with Go 1.26.6 on macOS:

  • Reproduced the input mutation using the issue's example; passing bytes.Clone preserved the original input and produced valid JSON.
  • go test ./... ./cmd/hujsonfmt/... and go vet ./... ./cmd/hujsonfmt/... passed.
  • go doc Standardize displays the guidance; gofmt -d format.go and git diff --check were clean.

Linux/Windows CI was not run locally. Prepared and reviewed with Codex assistance; commit includes DCO sign-off.

Fixes #57.

Fixes tailscale#57.

Signed-off-by: jihtsan <15151999611@163.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.

Standardize modifies its input slice; the doc comment does not say so

1 participant