
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
github.com/RedisGraph/redisgraph-go
redisgraph-go
is a Golang client for the RedisGraph module. It relies on redigo
for Redis connection management and provides support for RedisGraph's QUERY, EXPLAIN, and DELETE commands.
Simply do:
$ go get github.com/redislabs/redisgraph-go
The complete redisgraph-go
API is documented on GoDoc.
package main
import (
"fmt"
"github.com/gomodule/redigo/redis"
rg "github.com/redislabs/redisgraph-go"
)
func main() {
conn, _ := redis.Dial("tcp", "0.0.0.0:6379")
defer conn.Close()
graph := rg.GraphNew("social", conn)
john := rg.Node{
Label: "person",
Properties: map[string]interface{}{
"name": "John Doe",
"age": 33,
"gender": "male",
"status": "single",
},
}
graph.AddNode(&john)
japan := rg.Node{
Label: "country",
Properties: map[string]interface{}{
"name": "Japan",
},
}
graph.AddNode(&japan)
edge := rg.Edge{
Source: &john,
Relation: "visited",
Destination: &japan,
}
graph.AddEdge(&edge)
graph.Commit()
query := `MATCH (p:person)-[v:visited]->(c:country)
RETURN p.name, p.age, c.name`
// result is a QueryResult struct containing the query's generated records and statistics.
result, _ := graph.Query(query)
// Pretty-print the full result set as a table.
result.PrettyPrint()
// Iterate over each individual Record in the result.
for result.Next() { // Next returns true until the iterator is depleted.
// Get the current Record.
r := result.Record()
// Entries in the Record can be accessed by index or key.
p_name := r.GetByIndex(0)
fmt.Printf("\nName: %s\n", p_name)
p_age, _ := r.Get("p.age")
fmt.Printf("\nAge: %d\n", p_age)
}
// Path matching example.
query = "MATCH p = (:Person)-[:Visited]->(:Country) RETURN p"
result, _ = graph.Query(query)
res.Next()
r := res.Record()
p, ok := r.GetByIndex(0).(Path)
fmt.Printf("%s", p)
}
Running the above produces the output:
+----------+-------+--------+
| p.name | p.age | c.name |
+----------+-------+--------+
| John Doe | 33 | Japan |
+----------+-------+--------+
Query internal execution time 1.623063
Name: John Doe
Age: 33
A simple test suite is provided, and can be run with:
$ go test
The tests expect a Redis server with the RedisGraph module loaded to be available at localhost:6379
redisgraph-go is distributed under the BSD3 license - see LICENSE
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.