libgenders

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2025 License: MIT Imports: 4 Imported by: 0

README

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

Documentation

Index

Constants

View Source
const DefaultGendersFilepath = "/etc/genders"

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(path string) (Database, error)

func (Database) GetNodeAttr

func (d Database) GetNodeAttr(name, attr string) (string, bool)

func (Database) GetNodes

func (d Database) GetNodes() []Node

func (Database) Query

func (d Database) Query(query string) ([]Node, error)

type Node

type Node struct {
	Name       string
	Attributes map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL