diff options
author | Joe <rbo@gmx.us> | 2023-12-15 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2023-12-15 20:20:20 +0100 |
commit | 8945d49e7ae4b96b2919fd074c03623a7c65b8f8 (patch) | |
tree | a538134f49219d34aee0b762e8d7b40a42598e20 /c_init.go | |
parent | new stuff (diff) | |
download | hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.gz hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.bz2 hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.xz hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.tar.zst hardflip-8945d49e7ae4b96b2919fd074c03623a7c65b8f8.zip |
good parsing
Diffstat (limited to '')
-rw-r--r-- | c_init.go | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -84,21 +84,24 @@ func c_get_data_dir() string { // this function recurses into the specified root directory in order to load // every yaml file into memory -func c_recurse_data_dir(dir string, root string) { +func c_recurse_data_dir(dir string, root string, lhost *HostList) { files, err := ioutil.ReadDir(root + dir) if err != nil { c_die("could not read data directory", err) } for _, file := range files { if file.IsDir() == true { - c_recurse_data_dir(dir + file.Name() + "/", root) + c_recurse_data_dir(dir + file.Name() + "/", root, lhost) } else if filepath.Ext(file.Name()) == ".yml" { - fmt.Println(root + dir + file.Name()) - c_read_yaml_file(root + dir + file.Name()) + fmt.Println(dir + file.Name()) + host := c_read_yaml_file(root + dir + file.Name()) + lhost.add_back(host) } } } -func c_load_data_dir(dir string) { - c_recurse_data_dir("", dir + "/") +func c_load_data_dir(dir string) *HostList { + lhost := HostList{} + c_recurse_data_dir("", dir + "/", &lhost) + return &lhost } |