Drive the same Rust core the CLI uses from Go — through a stable C ABI via cgo, no shelling out. Analyze builds, preview update cost, pack, plan, apply, verify and benchmark, with context.Context cancellation and streaming progress events.
Import .../sdks/go/cavs. Requires Go 1.21+ and a C toolchain (cgo).
The compiled Rust library ships per platform (linux / macOS / windows, x86_64 & arm64) with a checksum.
Same repository and engine as the CLI. No CAVS-hosted infrastructure required.
Released builds ship the platform library; for a source checkout, make native builds and stages it from the Rust workspace. CAVS_SDK_LIBRARY overrides the path.
package main
import (
"context"
"fmt"
"github.com/orelvis15/cavs-oss/sdks/go/cavs"
)
func main() {
client, err := cavs.New()
if err != nil {
panic(err)
}
defer client.Close()
preview, err := client.Preview(context.Background(), cavs.PreviewRequest{
OldPath: "Build_v1",
NewPath: "Build_v2",
Policy: cavs.PolicyBalanced,
})
if err != nil {
panic(err)
}
fmt.Println("Recommended route:", preview.RecommendedRoute)
for _, r := range preview.Routes {
fmt.Printf(" %-16s %d bytes\n", r.Name, r.NetworkBytes)
}
}
Every method takes a context.Context (cancellation propagates to the native job) and a typed request, and returns a typed report. Pass cavs.WithProgress(fn) to stream ProgressEvents.
Analyze(ctx, AnalyzeRequest{OldPath, NewPath})PackDirectory(ctx, PackDirectoryRequest{InputDir, OutputCavs})Preview(ctx, PreviewRequest{OldPath, NewPath, Policy})CreatePlan(ctx, CreatePlanRequest{OldPath, NewPath, OutputPlan})ApplyPlan(ctx, ApplyPlanRequest{OldPath, PlanPath, OutputPath})VerifyInstall(ctx, VerifyRequest{Target, Signature})Benchmark(ctx, BenchmarkRequest{OldPath, NewPath})EstimateSavings(ctx, SavingsRequest{PricePerGB, MonthlyDownloads, …})ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
plan, err := client.CreatePlan(ctx, cavs.CreatePlanRequest{
OldPath: "Build_v1",
NewPath: "Build_v2",
OutputPlan: "update.cavsplan",
}, cavs.WithProgress(func(e cavs.ProgressEvent) {
fmt.Printf("[%s] %s\n", e.Type, e.Phase)
}))
if err != nil {
// Typed errors carry the stable engine code.
if cavs.IsCode(err, cavs.CodePathNotFound) {
log.Fatal("old build not found")
}
panic(err)
}
fmt.Println("reused bytes:", plan.ReusedBytes)
# .github/workflows/cavs-preview.yml
name: CAVS Preview
on: [push]
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version: stable }
- run: make -C sdks/go native
- run: go run ./cmd/preview --old Build_v1 --new Build_v2
Fail the job when the estimated update exceeds a budget, or upload the preview as a build artifact — the report is plain structs you can marshal to JSON.