Go SDK
Go APIs take context.Context, return typed errors, and make cleanup explicit.
go get github.com/cofy-x/axern/sdk/go@<version>Replace <version> with the Axern release used by the gateway and runtime; the Go SDK is not a floating latest dependency.
Use a published SDK version that matches the Axern gateway and runtime, and review the corresponding release notes before upgrading.
The official module is indexed on pkg.go.dev.
ctx := context.Background()client, err := axern.NewClient(ctx, "127.0.0.1:25000")if err != nil { log.Fatal(err)}defer client.Close()
sandbox, err := axern.NewSandbox(axern.SandboxOptions{ Client: client, Image: "docker.io/library/python:3.12-slim",})if err != nil { log.Fatal(err)}defer sandbox.Close(ctx)
if err := sandbox.Start(ctx); err != nil { log.Fatal(err)}
result, err := sandbox.Exec( ctx, "python -c \"print('hello from Go')\"", axern.ExecOptions{Check: true},)if err != nil { log.Fatal(err)}fmt.Print(result.StdoutString())Prefer defer sandbox.Close(ctx) for SDK-owned sandboxes. Branch on helpers such as IsNotFound, IsTimeout, and IsValidation rather than parsing error text.