mirror of
https://github.com/hanzoai/o11y-foundry.git
synced 2026-10-30 18:26:45 +00:00
## Summary
- Split material domain into writer-facing `Material` and
traversal-capable `StructuredMaterial` interfaces with concrete
`YAMLMaterial`, `JSONMaterial`, `INIMaterial`, and `BlobMaterial` types.
- Inline INI and YAML format helpers into their respective material
types and remove `format.go` and `ini.go`.
- Rename interface methods for clarity: `Contents` → `JSONContents`,
`WithContents` → `CloneWithJSONContents`, `IsMultiDoc` →
`HasMultipleDocuments`.
- Switch material constructors to `internal/errors` with
`TypeInvalidInput` for parse failures, `TypeInternal` for canonical-JSON
marshaling failures, and `TypeNotFound` for missing traversal paths.
- Add `MustNew{JSON,YAML,INI}Material` constructors and split tests into
per-type `*_material_test.go` files.
- Tighten interface doc comments to follow godoc convention (lead with
identifier, drop pure restatement, document the gjson dotted-key path
syntax).
- Move `ini.PrettyFormat = false` into a package `init()` so the global
is touched once instead of on every `FmtContents` call.
24 lines
369 B
Go
24 lines
369 B
Go
package domain
|
|
|
|
var _ Material = BlobMaterial{}
|
|
|
|
type BlobMaterial struct {
|
|
contents []byte
|
|
path string
|
|
}
|
|
|
|
func NewBlobMaterial(contents []byte, path string) BlobMaterial {
|
|
return BlobMaterial{
|
|
contents: contents,
|
|
path: path,
|
|
}
|
|
}
|
|
|
|
func (m BlobMaterial) Path() string {
|
|
return m.path
|
|
}
|
|
|
|
func (m BlobMaterial) FmtContents() []byte {
|
|
return m.contents
|
|
}
|