SDK Go (Golang)

Library resmi smallpict-go untuk arsitektur microservices Go berkecepatan tinggi.

SDK Go (smallpict-go)

SDK resmi SmallPict untuk Go dirancang efisien dengan penandatanganan HMAC zero-allocation dan context handling.


📦 Instalasi

go get github.com/tuxnoob/smallpict-go

🚀 Contoh Penggunaan Cepat

package main

import (
	"context"
	"fmt"
	"os"

	smallpict "github.com/tuxnoob/smallpict-go"
)

func main() {
	client := smallpict.NewClient(
		os.Getenv("SMALLPICT_API_KEY"),
		os.Getenv("SMALLPICT_SECRET_KEY"),
	)

	ctx := context.Background()

	fileBytes, _ := os.ReadFile("hero.png")
	result, err := client.Optimize(ctx, fileBytes, smallpict.OptimizeOptions{
		Format:   "avif",
		Quality:  85,
		MaxWidth: 1920,
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("URL Teroptimasi: %s (Hemat %.2f%%)\n", result.URL, result.SavingsPercentage)
}