Skip to content

feat(mpd): add WriteXML and Period.Write/WriteToString#56

Merged
tobbee merged 2 commits into
mainfrom
feat/write-period
Jun 25, 2026
Merged

feat(mpd): add WriteXML and Period.Write/WriteToString#56
tobbee merged 2 commits into
mainfrom
feat/write-period

Conversation

@tobbee

@tobbee tobbee commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Extract the XML encoder logic from (*MPD).Write into an exported
    WriteXML(elem any, w io.Writer, indent string, withHeader bool) that can
    serialize any element. (*MPD).Write now delegates to it.
  • Add (*Period).Write(w, indent) and (*Period).WriteToString(indent) for
    serializing a single Period fragment (no XML declaration).
  • Clean up the doc comments on the new functions.
  • Drop the goconst linter, which only flagged pre-existing repeated string
    literals (mostly test fixtures) across the package.

Tests

Added to mpd/io_test.go:

  • TestWriteXMLWriteXML and (*MPD).Write produce identical output, the
    returned byte count matches bytes written, and withHeader toggles the
    <?xml declaration.
  • TestPeriodWriteToString / TestPeriodWrite — a bare <Period> fragment
    renders with the expected attributes and no XML declaration, and Write
    agrees with WriteToString.

go test ./mpd/ and go vet ./mpd/ are green.

CHANGELOG

Added an Added entry under [Unreleased].

🤖 Generated with Claude Code

tobbee added 2 commits June 25, 2026 18:25
Extract the encoder logic from (*MPD).Write into an exported WriteXML
that serializes any element, and add Period.Write/WriteToString for
writing a single Period fragment. Add tests and clean up doc comments.
It flags pre-existing repeated string literals across the package
(mostly test fixtures) without enough value to justify the churn.
@tobbee
tobbee merged commit e7f37fd into main Jun 25, 2026
7 checks passed
@tobbee
tobbee deleted the feat/write-period branch June 25, 2026 16:30
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