Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 656 Bytes

README.md

File metadata and controls

37 lines (28 loc) · 656 Bytes

Libgenders

An implementation of libgenders in Go.

Usage

package main

import (
	"fmt"
	"log"

	"github.com/ryanmoran/libgenders"
)

func main() {
	database, err := libgenders.NewDatabase(libgenders.DefaultGendersFilepath)
	if err != nil {
		log.Fatal(err)
	}

	value, ok := database.GetNodeAttr("node1", "attr2")
	if ok {
		fmt.Println(value)
	}

	nodes, err := database.Query("~(attr1 -- ((attr1 && attr3) || (attr1 && attr5)))")
	if err != nil {
		log.Fatal(err)
	}

	for _, node := range nodes {
		fmt.Printf("name: %s, attributes: %v\n", node.Name, node.Attributes)
	}
}