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 | |
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 | ||||
-rw-r--r-- | c_josh.go | 9 | ||||
-rw-r--r-- | c_lhosts.go | 2 | ||||
-rw-r--r-- | c_parse.go | 2 |
4 files changed, 18 insertions, 10 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 } @@ -47,9 +47,16 @@ package main +import "fmt" + func main() { var data_dir string data_dir = c_get_data_dir() - c_load_data_dir(data_dir) + lhost := c_load_data_dir(data_dir) + curr := lhost.head + for curr != nil { + fmt.Println(*curr) + curr = curr.next + } } diff --git a/c_lhosts.go b/c_lhosts.go index d2cb992..aa32681 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * josh: src/c_lhosts.go - * Fri, 15 Dec 2023 10:01:11 +0100 + * Fri, 15 Dec 2023 11:43:34 +0100 * Joe * * the hosts linked list @@ -48,7 +48,6 @@ package main import ( - "fmt" "io/ioutil" "gopkg.in/yaml.v3" ) @@ -69,6 +68,5 @@ func c_read_yaml_file(file string) *HostNode { if host.Port == 0 { host.Port = 22 } - fmt.Println(host) return &host } |