sdk
All apps

Go SDK

pkg.go.dev

Idiomatic Go client with context cancellation and zero dependencies

Gallery

About

Standard-library-only Go SDK designed for high-concurrency microservices, Cloudflare Workers via Go WASM, and Kubernetes operators.

Features

  • First-class `context.Context` cancellation and deadline control
  • Zero external runtime dependencies — stdlib `net/http` based
  • Idiomatic error unwrapping via `errors.Is` and `errors.As`
  • Thread-safe connection pooling and rate-limited transport

Code Quickstart

main.gogo
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	shaf "github.com/shaf-is/shaf-go"
)

func main() {
	client := shaf.NewClient("your-api-key")
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	link, err := client.Create(ctx, &shaf.CreateOptions{
		URL:   "https://cloudflare.com",
		Alias: "cf-edge",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Created short link:", link.ShortURL)
}