Go quick start

In this quick start you'll learn how to start delivering your media from Cloudinary using the cloudinary-go library.

If you aren't familiar with Cloudinary, you may want to first take a look at the Developer get started guide for a high-level overview of integrating Cloudinary into your code, and an introduction to the main concepts.

You may also find our Glossary helpful to understand Cloudinary-specific terminology.

To get a more in-depth understanding, you may want to start from the Go SDK introduction.

1. Install library

Navigate to the directory where your Go program will be saved and run the following lines:

Copy to clipboard
go mod init my_folder
Copy to clipboard
go get github.com/cloudinary/cloudinary-go/v2

2. Add Cloudinary to your code

Copy to clipboard
// 1. Import the required packages for upload and admin

import (

// 2. Add your Cloudinary credentials and create a context

cld, _ := cloudinary.NewFromParams("<your-cloud-name>", "<your-api-key>", "<your-api-secret>")
ctx := context.Background()

// 3. Upload an image

resp, err := cld.Upload.Upload(ctx, "apple.png", uploader.UploadParams{PublicID: "docs/sdk/go/apple",
    Transformation: "c_crop,g_center/q_auto/f_auto", Tags: []string{"fruit"}})

// 4. Get your image information

my_image, err := cld.Image("docs/sdk/go/apple")
if err != nil {

// 5. Transform your image

// Resize to 250 x 250 pixels using the 'fill' crop mode.
my_image.Transformation = "c_fill,h_250,w_250"

// 6. Generate your image URL

url, err := my_image.String()
if err != nil {

// 7. Deliver your image

// Render the image in an HTML page.
tmpl := template.Must(template.ParseFiles("transformations.html"))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  tmpl.Execute(w, url)

3. See the result!

Transformed image

4. Try it yourself

Here's the code in a fully functioning Go app, along with some other examples that you'll find throughout this guide. It's structured a little differently from above - each transformation example has its own Go file showing the imports and syntax required. Find those files in the go/src/lib folder of the project.

main.go imports all the functions to display the transformed images on a simple web page.

Experiment with images:

This code is also available in GitHub.

Experiment with videos:

This code is also available in GitHub

Ready to learn more?

  • Understand the architecture of the Go SDK and get a more detailed overview of the libraries.
  • Learn how to upload images and videos using @cloudinary/cloudinary-go.

✔️ Feedback sent!

Rate this page: