Skip to content

Commit

Permalink
Adds basic README
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmoran committed Feb 14, 2024
1 parent cd8f0b1 commit c89211e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Libgenders

An implementation of [libgenders](https://github.com/chaos/genders/tree/master/src/libgenders) in Go.

## Usage

```go
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)
}
}
```

0 comments on commit c89211e

Please sign in to comment.