8000 Reject unsupported JSON map key kinds by dajiaohuang · Pull Request #1787 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

Reject unsupported JSON map key kinds - #1787

Open
dajiaohuang wants to merge 3 commits into
dominikh:masterfrom
dajiaohuang:fix/sa1026-json-map-keys
Open

dajiaohuang wants to merge 3 commits into
dominikh:masterfrom
dajiaohuang:fix/sa1026-json-map-keys

Conversation

@dajiaohuang
@dajiaohuang dajiaohuang commented Oct 1, 2026 •
Copy link
Copy Markdown

The static JSON marshal model currently accepts every basic map key type, but encoding/json only supports string and integer keys (unless a key implements encoding.TextMarshaler). This misses bool, float, and complex keys, which fail at runtime. Restrict builtin support to strings and integers and add analyzer regression cases.

Review update: the unrelated generic-instantiation change and its fixture were removed through a normal follow-up commit; #1764 tracks that fix separately. Current-head validation: go test ./staticcheck/sa1026 (three tests) passed; git diff --check passed. Prior validation text above is historical unless repeated here.

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

0