Skip to content

refactor: replace hand-rolled INI parser with gopkg.in/ini.v1#1

Merged
yetmike merged 2 commits intomainfrom
refactor/ini-v1-parser
Feb 17, 2026
Merged

refactor: replace hand-rolled INI parser with gopkg.in/ini.v1#1
yetmike merged 2 commits intomainfrom
refactor/ini-v1-parser

Conversation

@yetmike
Copy link
Copy Markdown
Owner

@yetmike yetmike commented Feb 17, 2026

Summary

  • Replace the custom line-based INI parser with gopkg.in/ini.v1 to fix a slice aliasing bug in replaceSection() that corrupted sections below when the replacement had more keys than the original
  • Preserve the same exported API (iniFile struct + all methods) so config.go needs only a one-line change
  • Rewrite tests to cover the same behaviors plus a regression test for the original bug

Test plan

  • go test ./... passes
  • Manual test: create config with small [default] and large [profile dev], switch to dev, verify all sections preserved

Mike and others added 2 commits February 17, 2026 22:10
The custom line-based INI parser had a slice aliasing bug in
replaceSection() — when replacing a section with more keys than the
original, append() mutated the underlying array and corrupted sections
below. Rather than patching the bug, replace the parser entirely with
the battle-tested gopkg.in/ini.v1 library.

The exported API (iniFile struct + all methods) is preserved so
config.go needs only a single change (len(ini.lines) == 0 → isEmpty()).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yetmike yetmike merged commit 66284fb into main Feb 17, 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.

1 participant