Skip to content

Feat/improve code quality - #1

Open
vinitkumar wants to merge 7 commits into
mainfrom
feat/improve-code-quality
Open

vinitkumar wants to merge 7 commits into
mainfrom
feat/improve-code-quality

Conversation

@vinitkumar

Copy link
Copy Markdown
Owner

No description provided.

vinitkumar and others added 7 commits March 27, 2026 00:04
- ToXML() now always returns ([]byte, error) instead of (any, error)
- ToXMLString() and ToXMLBytes() no longer need type assertions
- PrettyPrint() returns []byte instead of string
- Hoisted xmlDeclRegexp to package-level to avoid recompilation per call
- Updated all tests to remove type assertion gymnastics

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b62-e1bd-75cd-b932-147353861cc0
Co-authored-by: Amp <amp@ampcode.com>
math/rand/v2 is the modern API (auto-seeded, better ergonomics).
Replaces rand.Intn with rand.IntN.

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b62-e1bd-75cd-b932-147353861cc0
Co-authored-by: Amp <amp@ampcode.com>
Previously, extractSpecialAttrs called delete() on the input map,
meaning the same data passed twice would produce different results.
Now builds a shallow copy with special keys stripped instead.

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b62-e1bd-75cd-b932-147353861cc0
Co-authored-by: Amp <amp@ampcode.com>
Prevents infinite hangs on slow or unresponsive servers.

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b62-e1bd-75cd-b932-147353861cc0
Co-authored-by: Amp <amp@ampcode.com>
Replaced init() + package-level vars with a testable run() function
that accepts args, stdin, stdout, stderr. CLI now has 11 tests covering
help, version, string input, stdin, file, output-to-file, error cases,
XPath format, and custom wrapper.

Fixed .gitignore to use root-anchored patterns so the cmd/json2xml-go/
directory is not accidentally ignored.

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b62-e1bd-75cd-b932-147353861cc0
Co-authored-by: Amp <amp@ampcode.com>
Replaced fragile err.Error() == "EOF" with err == io.EOF
in KeyIsValidXML and PrettyPrint.

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b62-e1bd-75cd-b932-147353861cc0
Co-authored-by: Amp <amp@ampcode.com>
These options existed in Options but were not exposed through the
JSON2xml builder, forcing users to drop down to DictToXML directly.

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b62-e1bd-75cd-b932-147353861cc0
Co-authored-by: Amp <amp@ampcode.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.

1 participant