File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ import (
12
12
"github.com/tidwall/gjson"
13
13
)
14
14
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.
15
22
func LoadConfig (bts []byte , cfg any ) error {
16
23
bts , err := hujson .Standardize (bts )
17
24
if err != nil {
@@ -52,6 +59,9 @@ func loadTypeReg(typ string) (any, error) {
52
59
return factory , nil
53
60
}
54
61
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.
55
65
func Register [T any ](name string , factory func () Builder [T ]) {
56
66
registry .Lock ()
57
67
defer registry .Unlock ()
You can’t perform that action at this time.
0 commit comments