Skip to content

Allow writes after SetData(nil) - #237

Merged
inhere merged 1 commit into
gookit:masterfrom
rupayon123:fix/set-after-nil-data-20261030
Oct 31, 2026
Merged

inhere merged 1 commit into
gookit:masterfrom
rupayon123:fix/set-after-nil-data-20261030

Conversation

@rupayon123

Copy link
Copy Markdown
Contributor

After SetData(nil), reads see an empty configuration, but writing a top-level or literal dotted key panics on assignment to the nil root map. Nested writes already initialize their path.

Initialize the missing root map inside the existing locked write path. Readonly/invalid-key checks still reject before allocation, and hooks/cache behavior is unchanged.

Go 1.26.0 / macOS arm64 validation:

  • Two failing write cases and three nested/readonly/invalid controls pass after the fix.
  • Full coverage and race suites each pass 217 leaf tests with no skips.
  • Twelve actual configuration/JSON scenarios complete three reset/reuse cycles each with no mismatches; pristine source fails eight scenarios.
  • Vet, build, formatting, tidy and the YAML example pass. Staticcheck and Revive retain their unchanged baseline findings.

Module files are unchanged. Other supported Go/OS combinations remain unverified locally; this does not add broader external-map ownership or read-side concurrency guarantees.

@inhere
inhere merged commit d711809 into gookit:master Oct 31, 2026
12 checks passed
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.

2 participants