filereader

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2026 YLD Limited SPDX-License-Identifier: Apache-2.0 Package filereader provides a generic, type-safe file reader that discovers files by extension and deserializes them into Go structs. It supports HCL and YAML formats with optional recursive directory traversal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader[T Updater] struct {
	// contains filtered or unexported fields
}

Reader discovers and reads files of a given type T from disk.

func New

func New[T Updater]() *Reader[T]

New returns a new Reader instance.

func (*Reader[T]) CtyYaml

func (read *Reader[T]) CtyYaml(content []byte) (T, error)

CtyYaml unmarshals YAML content via the cty type system into a value of type T.

func (*Reader[T]) FromHCL

func (read *Reader[T]) FromHCL(path string, recursive bool) (hcl.Body, error)

FromHCL reads HCL files from path, parses them, and returns a merged HCL body.

func (*Reader[T]) FromYaml

func (read *Reader[T]) FromYaml(path string, recursive bool) ([]T, error)

FromYaml reads YAML files from path and unmarshals each into a value of type T.

func (*Reader[T]) GetFiles

func (read *Reader[T]) GetFiles() []string

GetFiles returns the list of file paths discovered by the reader.

type Updater

type Updater interface {
	Update(string)
}

Updater is implemented by types that can receive a filename after being read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL