-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_modifying_data_test.go
42 lines (35 loc) · 1.31 KB
/
example_modifying_data_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
41
42
/*
Such code is primiarily used for fl-darklint. You could check its code for more examples
https://github.com/darklab8/fl-darklint
*/
package configs
import (
"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"
)
// ExampleModifyingData demononstrating how to change configs values
func Example_modifyingConfigs() {
freelancer_folder := configs_settings.Env.FreelancerFolder
configs := configs_mapped.NewMappedConfigs()
logus.Log.Debug("scanning freelancer folder", utils_logus.FilePath(freelancer_folder))
// Reading ini reading universal format
// and mapping to ORM objects
configs.Read(freelancer_folder)
// Modifying files
for _, base := range configs.Universe_config.Bases {
base.Nickname.Set(base.Nickname.Get())
base.System.Set(base.System.Get())
base.File.Set(base.File.Get())
}
for _, system := range configs.Universe_config.Systems {
system.Nickname.Set(system.Nickname.Get())
system.Msg_id_prefix.Set(system.Msg_id_prefix.Get())
if system.File.Get() != "" {
system.File.Set(system.File.Get())
}
}
// Write without Dry Run for writing to files modified values back!
configs.Write(configs_mapped.IsDruRun(true))
}