package main
import (
"fmt"
"log"
"github.com/HelixDB/helix-go"
)
func main() {
client := helix.NewClient("http://localhost:6969")
var central map[string]any
if err := client.Query("CreateLocation",
helix.WithData(map[string]any{"name": "Central Station"}),
).Scan(¢ral); err != nil {
log.Fatalf("CreateLocation (Central) failed: %s", err)
}
var market map[string]any
if err := client.Query("CreateLocation",
helix.WithData(map[string]any{"name": "Market Square"}),
).Scan(&market); err != nil {
log.Fatalf("CreateLocation (Market) failed: %s", err)
}
var harbor map[string]any
if err := client.Query("CreateLocation",
helix.WithData(map[string]any{"name": "Harbor"}),
).Scan(&harbor); err != nil {
log.Fatalf("CreateLocation (Harbor) failed: %s", err)
}
centralID := central["location"].(map[string]any)["id"].(string)
marketID := market["location"].(map[string]any)["id"].(string)
harborID := harbor["location"].(map[string]any)["id"].(string)
if err := client.Query("ConnectLocations",
helix.WithData(map[string]any{
"from_id": centralID,
"to_id": marketID,
"distance_km": uint32(2),
}),
).Scan(&map[string]any{}); err != nil {
log.Fatalf("ConnectLocations (Central -> Market) failed: %s", err)
}
if err := client.Query("ConnectLocations",
helix.WithData(map[string]any{
"from_id": marketID,
"to_id": harborID,
"distance_km": uint32(3),
}),
).Scan(&map[string]any{}); err != nil {
log.Fatalf("ConnectLocations (Market -> Harbor) failed: %s", err)
}
var result map[string]any
if err := client.Query("GetShortestPath",
helix.WithData(map[string]any{
"from_id": centralID,
"to_id": harborID,
}),
).Scan(&result); err != nil {
log.Fatalf("GetShortestPath failed: %s", err)
}
fmt.Printf("GetShortestPath result: %#v\n", result)
}