For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DocsAPI Reference
  • Fundamentals
    • Home
    • Why Skyflow?
    • Get started with Skyflow
    • Explore what Skyflow can do
    • Authenticate
    • Accounts and environments
    • Deployment models
    • Security best practices
    • Compliance and certifications
    • Get data into Skyflow
    • Platform FAQs
  • Governance
    • Overview
  • Tokenization
    • Overview
  • Connections
    • Overview
  • Processing
  • AI and data sanitization
    • Overview
  • SDKs
    • Overview
      • Go: Migrate from V1 to V2
      • Python: Migrate from V1 to V2
      • Node.js: Migrate from V1 to V2
      • Java: Migrate from V1 to V2
  • Elements
    • Collect and reveal data with Skyflow Elements
LogoLogo
Login
Login
On this page
  • Authentication
  • Initialize the client
  • Insert records
  • Request options
  • Error handling
SDKsOverview

Go SDK: Migrate from V1 to V2

Was this page helpful?
Previous

Python SDK: Migrate from V1 to V2

Next
Built with

Skyflow Go SDK v2 introduces a new authentication model, multi-vault support, native Go data structures, and richer error diagnostics. This guide walks through the key changes with before/after code examples.

Authentication

V1 required a token provider function. V2 lets you choose from five credential types.

V1:

1var bearerToken = ""
2
3func GetSkyflowBearerToken() (string, error) {
4 filePath := "<file_path>"
5 if saUtil.IsExpired(bearerToken) {
6 newToken, err := saUtil.GenerateBearerToken(filePath)
7 if err != nil {
8 return "", err
9 }
10 bearerToken = newToken.AccessToken
11 return bearerToken, nil
12 }
13 return bearerToken, nil
14}

V2:

1// Option 1: API key (recommended)
2skyflowCredentials := common.Credentials{ApiKey: "<YOUR_API_KEY>"}
3
4// Option 2: Environment variable — set SKYFLOW_CREDENTIALS in your environment
5
6// Option 3: Credentials file
7skyflowCredentials := common.Credentials{Path: "<YOUR_CREDENTIALS_FILE_PATH>"}
8
9// Option 4: Stringified JSON
10skyflowCredentials := common.Credentials{CredentialsString: "<YOUR_CREDENTIALS_STRING>"}
11
12// Option 5: Bearer token
13skyflowCredentials := common.Credentials{Token: "<BEARER_TOKEN>"}

Initialize the client

V2 uses a functional options pattern and supports multiple vaults per client instance. Log levels are now per-instance instead of global.

V1:

1configuration := common.Configuration{
2 VaultID: "<vault_id>",
3 VaultURL: "<vault_url>",
4 TokenProvider: GetToken,
5}
6skyflowClient := Skyflow.Init(configuration)

V2:

1creds := common.Credentials{Path: "<YOUR_CREDENTIALS_FILE_PATH>"}
2vaultConfig := common.VaultConfig{
3 VaultId: "<VAULT_ID>",
4 ClusterId: "<CLUSTER_ID>",
5 Env: common.DEV,
6 Credentials: creds,
7}
8skyflowClient, err := client.NewSkyflow(
9 client.WithVaults(vaultConfig),
10 client.WithCredentials(common.Credentials{}),
11 client.WithLogLevel(logger.DEBUG),
12)

Key changes:

  • VaultURL is replaced by ClusterId
  • Env is now required (DEV, SANDBOX, PROD)
  • Log level is set per client instance

Insert records

V2 uses native Go maps and slices instead of third-party JSON objects. Responses use typed structs.

V1:

1var records = make(map[string]interface{})
2var record = make(map[string]interface{})
3record["table"] = "<your_table_name>"
4fields := map[string]interface{}{"<field_name>": "<field_value>"}
5record["fields"] = fields
6records["records"] = []interface{}{record}
7
8options := common.InsertOptions{
9 Tokens: true,
10 ContinueOnError: true,
11}
12res, err := skyflowClient.Insert(records, options)

V2:

1service, err := skyflowClient.Vault("<VAULT_ID>")
2if err != nil {
3 fmt.Println(err)
4 return
5}
6values := []map[string]interface{}{
7 {"<COLUMN_NAME>": "<COLUMN_VALUE>"},
8}
9insert, err := service.Insert(ctx, common.InsertRequest{
10 Table: "<TABLE_NAME>",
11 Values: values,
12}, common.InsertOptions{
13 ContinueOnError: false,
14 ReturnTokens: true,
15})
16fmt.Println(insert)

V1 response:

1{
2 "Records": [
3 {
4 "table": "cards",
5 "fields": {
6 "skyflow_id": "16419435-aa63-4823-aae7-19c6a2d6a19f",
7 "cardNumber": "f3907186-e7e2-466f-91e5-48e12c2bcbc1"
8 }
9 }
10 ]
11}

V2 response:

1{
2 "InsertedFields": [
3 {
4 "skyflow_id": "9fac9201-7b8a-4446-93f8-5244e1213bd1",
5 "card_number": "5484-7829-1702-9110",
6 "request_index": "0"
7 }
8 ],
9 "Errors": []
10}

Request options

V2 uses a functional options pattern for cleaner optional parameter handling.

V1:

1options := common.InsertOptions{
2 Tokens: true,
3 Upsert: upsertArray,
4 ContinueOnError: true,
5}

V2:

1options := common.InsertOptions{
2 ContinueOnError: false,
3 ReturnTokens: true,
4 TokenMode: common.DISABLE,
5 Upsert: "<UPSERT_COLUMN>",
6}

Error handling

V2 errors include more detail to help with debugging.

V1:

1{
2 "code": "<http_code>",
3 "description": "<description>"
4}

V2:

1{
2 "httpStatus": "<http_status>",
3 "grpcCode": "<grpc_code>",
4 "httpCode": "<http_code>",
5 "message": "<message>",
6 "requestId": "<request_id>",
7 "details": ["<details>"]
8}

Use the requestId field when contacting Skyflow support — it uniquely identifies the request for faster diagnosis.