-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader_plain.go
More file actions
25 lines (22 loc) · 953 Bytes
/
loader_plain.go
File metadata and controls
25 lines (22 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright The ActForGood Authors.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://github.com/actforgood/xconf/blob/main/LICENSE.
package xconf
// PlainLoader is an explicit go configuration map retriever.
// It simply returns a copy of the given config map parameter.
//
// It can be used for example:
//
// - in a [MultiLoader] (with allowing keys overwrite) as the first loader
// in order to specify default configurations.
//
// - to provide any application hardcoded configs.
func PlainLoader(configMap map[string]any) Loader {
// make a copy to preserve state at current time.
// (prevents user modification of configMap from outside while using the loader).
configMapCopy := DeepCopyConfigMap(configMap)
return LoaderFunc(func() (map[string]any, error) {
return DeepCopyConfigMap(configMapCopy), nil // make a copy for an eventual (safe) later mutation.
})
}