Skip to content

Commit 35351c0

Browse files
authored
Merge pull request #10 from runreveal/alan/loader-docs
add some docs to loader
2 parents 5c42afa + 337422c commit 35351c0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

loader/loader.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import (
1212
"github.com/tidwall/gjson"
1313
)
1414

15+
// LoadConfig loads a configuration from a byte slice into the given config.
16+
// The config must be a pointer to a struct.
17+
// It parses the byteslice as hujson, which allows for C-style comments and
18+
// trailing commas on arrays and maps.
19+
// It then unmarshals the JSON into the config struct.
20+
// Finally, it replaces any environment variables in the struct with their
21+
// values referenced by the corresponding environment variables.
1522
func LoadConfig(bts []byte, cfg any) error {
1623
bts, err := hujson.Standardize(bts)
1724
if err != nil {
@@ -52,6 +59,9 @@ func loadTypeReg(typ string) (any, error) {
5259
return factory, nil
5360
}
5461

62+
// Register registers a factory method for a type T with the given type name. T
63+
// is typically an interface that is implmented by the struct of type given by
64+
// the name.
5565
func Register[T any](name string, factory func() Builder[T]) {
5666
registry.Lock()
5767
defer registry.Unlock()

0 commit comments

Comments
 (0)