-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_export_test.go
40 lines (34 loc) · 1.39 KB
/
example_export_test.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Such code is primiarily used for fl-darkstat. You could check its code for more examples
https://github.com/darklab8/fl-darkstat
*/
package configs
import (
"fmt"
"github.com/darklab8/fl-configs/configs/configs_export"
"github.com/darklab8/fl-configs/configs/configs_mapped"
"github.com/darklab8/fl-configs/configs/configs_settings"
"github.com/darklab8/fl-configs/configs/configs_settings/logus"
"github.com/darklab8/go-utils/utils/utils_logus"
)
// ExampleExportingData demonstrating exporting freelancer folder data for comfortable usage
func Example_exportingData() {
freelancer_folder := configs_settings.Env.FreelancerFolder
configs := configs_mapped.NewMappedConfigs()
logus.Log.Debug("scanning freelancer folder", utils_logus.FilePath(freelancer_folder))
// Reading to ini universal custom format and mapping to ORM objects
// which have both reading and writing back capabilities
configs.Read(freelancer_folder)
// For elegantly exporting enriched data objects with better type safety for just reading access
// it is already combined with multiple configs sources for flstat view
exported := configs_export.Export(configs, configs_export.ExportOptions{})
for _, base := range exported.Bases {
// do smth with exported bases
fmt.Println(base.Name)
fmt.Println(base.Infocard)
fmt.Println(base.System)
fmt.Println(base.SystemNickname)
fmt.Printf("%d\n", base.InfocardID)
break
}
}