Skip to content

section: return a zero-value Key for empty names - #395

Merged
unknwon merged 2 commits into
go-ini:v1from
team-humaki:key-empty-name-zero-value
Nov 11, 2026
Merged

unknwon merged 2 commits into
go-ini:v1from
team-humaki:key-empty-name-zero-value

Conversation

@team-humaki

Copy link
Copy Markdown

Fixes #358

Section.Key is documented to return a zero-value when the name is missing. NewKey still rejects empty names, and the error was discarded, so Key("") was nil.

Return a zero-value Key instead of inserting an empty name. NewKey("") still errors.

team-humaki and others added 2 commits September 16, 2026 18:00
Key() documents a zero-value when the name is missing, but NewKey
rejects empty names and the error was discarded, so Key("") was nil
and paniced callers. Return newKey instead of inserting an empty name.

Fixes go-ini#358
The Key returned for an empty name isn't in the section, so setting its
value must not add an entry that KeysHash shows but nothing writes or
deletes.
@unknwon
unknwon merged commit 247c436 into go-ini:v1 Nov 11, 2026
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.

Section.Key passing a empty key name will return a nil

2 participants