func LoadDirectory(dir string, parser Parser) (err error) {

    // Open dir for reading
    d, err := os.Open(dir)
    if err != nil {
        return
    }

    // Iterate over all the files in the directory.
    for {

        // Only read 128 files at a time.
        if fis, err := d.Readdir(128); err == nil {

            // Read each entry
            for _, fi := range fis {
                // fmt.Println("%#v", fi)

                // If the FileInfo is a directory, read the directory.
                // Otherwise, read the file.
                switch fi.IsDir() {
                case true:

                    // return error if there is one
                    if err := LoadDirectory(fi.Name(), parser); err != nil {
                        return err
                    }
                case false:

                    // All schema files should end with .nt
                    if !strings.HasSuffix(fi.Name(), ".ent") {
                        break
                    }

                    // Read the file
                    if _, err := LoadFile(filepath.Join(dir, fi.Name()), parser); err != nil {
                        return err
                    }
                }
            }
        } else if err == io.EOF {
            // If there are no more files in the directory, break.
            break
        } else {
            // If there is any other error, return it.
            return err
        }
    }

    // If you have reached this far, you are done.
    return nil
}
func LoadDirectory(dir string, parser Parser) (err error) {

    // Open dir for reading
    d, err := os.Open(dir)
    if err != nil {
        return
    }

    // Iterate over all the files in the directory.
    for {

        // Only read 128 files at a time.
        if fis, err := d.Readdir(128); err == nil {

            // Read each entry
            for _, fi := range fis {
                // fmt.Println("%#v", fi)

                // If the FileInfo is a directory, read the directory.
                // Otherwise, read the file.
                switch fi.IsDir() {
                case true:

                    // return error if there is one
                    if err := LoadDirectory(fi.Name(), parser); err != nil {
                        return err
                    }
                case false:

                    // All schema files should end with .nt
                    if !strings.HasSuffix(fi.Name(), ".ent") {
                        break
                    }

                    // Read the file
                    if _, err := LoadFile(filepath.Join(dir, fi.Name()), parser); err != nil {
                        return err
                    }
                }
            }
        } else if err == io.EOF {
            // If there are no more files in the directory, break.
            break
        } else {
            // If there is any other error, return it.
            return err
        }
    }

    // If you have reached this far, you are done.
    return nil
}
// LoadDirectory reads all the schema files from a directory.