refactor: Align with Go conventions and improve maintainability

Renames the `OriginalUrl` field to `OriginalURL` across media models to adhere to Go's common initialisms convention. The `json` tag is unchanged to maintain API compatibility.

Introduces constants for exporter formats (e.g., `FormatMarkdown`, `FormatDocx`) to eliminate the use of magic strings, enhancing type safety and making the code easier to maintain.

Additionally, this commit includes several minor code quality improvements:
- Wraps file-writing errors in exporters to provide more context.
- Removes redundant package-level comments from test files.
- Applies various minor linting fixes throughout the codebase.
This commit is contained in:
2025-11-06 16:45:25 +01:00
parent d8e4d97841
commit b56c9fa29f
26 changed files with 53 additions and 77 deletions

View File

@ -1,4 +1,3 @@
// Package exporters_test provides tests for the docx exporter.
package exporters
import (
@ -331,7 +330,7 @@ func TestDocxExporter_ComplexCourse(t *testing.T) {
Caption: "<p>Watch this introductory video</p>",
Media: &models.Media{
Video: &models.VideoMedia{
OriginalUrl: "https://example.com/intro.mp4",
OriginalURL: "https://example.com/intro.mp4",
Duration: 300,
},
},
@ -359,7 +358,7 @@ func TestDocxExporter_ComplexCourse(t *testing.T) {
Caption: "<p>Course overview diagram</p>",
Media: &models.Media{
Image: &models.ImageMedia{
OriginalUrl: "https://example.com/overview.png",
OriginalURL: "https://example.com/overview.png",
},
},
},