Skip to content
smallPict
Start free
HomeIntegrationsGolang SDK

Concurrent production pipeline for Go microservices

Clean, idiomatic Go library for processing image uploads, user avatars, and media files in Gin, Fiber, Echo, or standard net/http services.

Install

GO Package
$ go get github.com/smallpict/smallpict-go

Implementation example

go
package main

import (
	"context"
	"fmt"
	"os"
	"github.com/smallpict/smallpict-go"
)

func main() {
	client := smallpict.NewClient("sp_live_key_xxxxx")
	
	file, _ := os.Open("user_avatar.png")
	defer file.Close()

	result, err := client.Optimize(context.Background(), file, smallpict.Options{
		Format:  smallpict.FormatWebP,
		Quality: 82,
		Width:   400,
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Optimized URL: %s | Size: %d bytes (-%d%%)\n", 
		result.URL, result.OptimizedSize, result.SavingsPercentage)
}

Integration steps

  1. go get package

    Install the official Go module into your project.

  2. Initialize client

    Pass your SmallPict API Key to smallpict.NewClient().

  3. Plug into upload handlers

    Wrap user file uploads with client.Optimize() before saving to S3/R2.

Key benefits

  • Context cancellation and timeout support
  • Memory-efficient io.Reader / io.Writer streaming
  • Connection pooling with HTTP/2 Keep-Alive
  • Native BYO-Storage destination headers

Need complete implementation guides & API specs?

Explore parameter references, authentication mechanisms, error codes, and local testing instructions in our official Golang SDK developer guide.

Read Golang SDK Docs

Speed Up Your Golang SDK Image Pipeline

Try AVIF and WebP image optimization in your application. No setup fee, and sandbox keys right away.