Go SDK
Use silos-sdk-go to manage databases and branches and run SQL from Go services.
The Go SDK (silos-sdk-go) lets you provision and manage Silos databases and
branches from Go, and run SQL against them. It's a thin, typed wrapper over the same
management API used by the Console and
CLI.
The Go SDK is available and evolving. The snippet below shows the minimal install-and-connect path. For authoritative request and response shapes, see the API reference.
Install
go get github.com/silos-sh/silos-sdk-goInitialize the client
Read your API key from the environment and construct a client.
package main
import (
"context"
"log"
"os"
silos "github.com/silos-sh/silos-sdk-go"
)
func main() {
client := silos.NewClient(os.Getenv("SILOS_API_KEY"))
db, err := client.Databases.Create(context.Background(), silos.CreateDatabase{
Name: "my-app",
})
if err != nil {
log.Fatal(err)
}
log.Printf("created database %s", db.Name)
}Method and type names track the management API and may change as the SDK matures. The API reference is canonical for the exact surface.
Run SQL with a standard driver
For application data access, the simplest path is a standard Postgres driver such as
pgx, using the database's connection string.
Silos speaks the Postgres wire protocol, so no Silos-specific driver is required.
package main
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v5"
)
func main() {
conn, err := pgx.Connect(context.Background(), os.Getenv("SILOS_DATABASE_URL"))
if err != nil {
panic(err)
}
defer conn.Close(context.Background())
var now string
if err := conn.QueryRow(context.Background(), "SELECT now()").Scan(&now); err != nil {
panic(err)
}
fmt.Println(now)
}Your SILOS_DATABASE_URL looks like:
postgres://user:password@db-xxxx.silos.sh/main?sslmode=requireTLS is required — keep sslmode=require.