Skip to content
Go SDK

Go SDK

Getting Started

Install the SDK to your project like so:

# Make sure the version at the end matches the version of your warehouse server
go get codeberg.org/ultravioletasdf/warehouse/pkg/sdk@v0.20.0

And connect to the master server using the code:

package main

import (
  "context"
	
  warehouse "codeberg.org/ultravioletasdf/warehouse/pkg/sdk"
)

func main() {
  // In real code, never hardcode connection config like this. Instead, load the master address and API key from environment variables
  // The context returned should be used for all requests, as it passes the API key.
  client, ctx, err := warehouse.NewClient(context.Background(), warehouse.ConnectionConfig{
    MasterAddress: "localhost:3000",
    ApiKey: "test",
    Secure: false,
  })
  if err != nil {
    panic("Failed to connect to Warehouse server")
  }
}