Skip to content

Go SDK

The Go client in development covers your app’s users, table queries, file storage and functions. It uses only the Go standard library, every call takes a context.Context, and it is safe for concurrent use. This page describes that client, so you can plan for it. Until it can be installed, call the REST API from Go.

import vaif "github.com/vaifllc/vaif-go"
client, err := vaif.NewClient("YOUR_PROJECT_ID", "vk_pub_...")
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
if _, err := client.Auth.SignIn(ctx, "ada@example.com", "a strong password"); err != nil {
log.Fatal(err)
}
todos, err := client.From("todos").Eq("done", false).Order("created_at", true).Limit(20).List(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(todos.Count, todos.Data)
  • Auth: SignUp, SignIn, VerifyMFA, GetUser, RequestPasswordReset, ResetPassword and SignOut. The access token refreshes itself 30 seconds before it expires.
  • Tables: From(table) with Eq, Neq, Gt, Gte, Lt, Lte, Like, ILike and In, then List, Paginate, Get, First, Insert, InsertMany, Upsert, Update and Delete.
  • Storage: Upload, Download, CreateSignedURL and CreateSignedUploadURL.
  • Functions: Invoke.
  • Retries: GET, HEAD and OPTIONS requests are retried on 429 and 5xx responses and on network errors. Writes are never replayed once they may have reached the server.

Use a publishable vk_pub_ key in apps. A secret vk_srv_ key bypasses row rules and belongs on trusted servers only.