Go 마이크로서비스를 위한 동시성 프로덕션 파이프라인
Gin, Fiber, Echo 또는 표준 net/http 서비스에서 이미지 업로드, 프로필 아바타, 미디어 파일을 효율적으로 처리하는 Go 라이브러리.
설치
GO 패키지
$ go get github.com/smallpict/smallpict-go구현 예제
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)
}연동 단계
go get으로 패키지 설치
프로젝트에 공식 Go 모듈을 추가합니다.
클라이언트 초기화
smallpict.NewClient()에 API 키를 전달합니다.
업로드 핸들러 연동
S3/R2에 저장하기 전 client.Optimize()로 감싸줍니다.
핵심 장점
- 컨텍스트 취소 및 타임아웃 완벽 지원
- 메모리 효율적인 io.Reader / io.Writer 스트리밍
- HTTP/2 Keep-Alive를 통한 커넥션 풀링
- 자체 클라우드 스토리지(BYO-Storage) 대상 헤더 네이티브 지원
Golang SDK 이미지 파이프라인 속도 높이기
애플리케이션에서 AVIF 및 WebP 이미지 최적화를 사용해 보세요. 설치 비용 없이 샌드박스 키를 즉시 발급합니다.