Programmable Media

Go sample projects

Last updated: Mar-10-2025

We've created some sample projects to get you started with integrating Cloudinary into your Go applications.

Tip
Check out our collection of Go code explorers too!

Image transformations

The Image transformations app showcases popular on-the-fly image transformations using the Go SDK, including special effects, resizing, subject-aware cropping with gravity parameters, optimization, and overlays.

Here's what you'll see in the Image transformations app:

Video Player is loading.
Current Time 0:00
Duration -:-
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
  • descriptions off, selected
  • captions off, selected


    Here's an excerpt from the code featuring the Overlays and Resize_crop functions from files in the custom lib package:

    overlays_ex.go
    Go
    package lib
    
    import(
        "fmt"
        "github.com/cloudinary/cloudinary-go"
    )
    
    func Overlays(cld *cloudinary.Cloudinary) string {
        img_coffee, err := cld.Image("docs/sdk/go/coffee_cup")
        if err != nil {
            fmt.Println("error")
        }
    
        // Add the transformation
        img_coffee.Transformation = "w_400,h_250,c_fill,g_south/l_nice_couple,w_1.3,h_1.3,g_faces,c_crop,fl_region_relative/e_saturation:50/e_vignette/fl_layer_apply,w_100,r_max,g_center,y_20,x_-20/l_balloon,h_55/e_hue:-20,a_5/fl_layer_apply,x_30,y_5/l_text:Cookie_40_bold:Love,co_rgb:f08/a_20,fl_layer_apply,x_-45,y_44/c_crop,w_300,h_250,x_30/r_60"
    
        // Generate and print the delivery URL
        url, err := img_coffee.String()
        fmt.Println(url)
        if err != nil {
            fmt.Println("error")
        }
        return url
    }

    resize_crop_ex.go
    Go
    package lib
    
    import(
        "fmt"
        "github.com/cloudinary/cloudinary-go"
    )
    
    func Resize_crop(cld *cloudinary.Cloudinary) string {
        // Instantiate an object that stores information for asset with public ID "black_coat_portrait"
        img_fam, err := cld.Image("docs/sdk/go/family_video")
        if err != nil {
            fmt.Println("error")
        }
    
        // Add the transformation
        img_fam.Transformation = "w_350,h_350,c_fill,g_faces"
    
        // Generate and print the delivery URL
        url, err := img_fam.String()
        fmt.Println(url)
        if err != nil {
            fmt.Println("error")
        }
        return url
    }


    Video transformations

    The Video transformations app showcases popular on-the-fly video transformations using the Go SDK, including resizing, cropping, concatenation, trimming, overlays, and special effects.

    Here's what you'll see in the Video transformations app:

    Video Player is loading.
    Current Time 0:00
    Duration -:-
    Loaded: 0%
    Stream Type LIVE
    Remaining Time 0:00
     
    1x
    • descriptions off, selected
    • captions off, selected


      Here's an excerpt from the code featuring the Overlay and Concat functions from files in the custom lib package:

      overlay_ex.go
      Go
      package lib
      
      import(
          "fmt"
          "github.com/cloudinary/cloudinary-go"
      )
      
          func Overlay(cld *cloudinary.Cloudinary) string {
            // Instantiate an object for the video with public ID "exercise1" in folder "docs/sdk/go"
            v_exercise, err := cld.Video("docs/sdk/go/exercise1")
            if err != nil {
                fmt.Println("error")
            }
      
            // Add the transformation
            v_exercise.Transformation = "c_scale,w_300/l_video:exercise2/c_fit,w_80/bo_2px_solid_blue/fl_layer_apply,g_north_east,so_2.0"
      
            // Generate and print the delivery URL
            myURL, err := v_exercise.String()
            if err != nil {
                fmt.Println("error")
            }
            fmt.Println(myURL)
      
            // Output: https://res.cloudinary.com/demo/video/upload/c_scale,w_300/l_video:exercise2/c_fit,w_80/bo_2px_solid_blue/fl_layer_apply,g_north_east,so_2.0/v1/docs/sdk/go/exercise1  
          return myURL
      }

      concat_ex.go
      Go
      package lib
      
      import(
          "fmt"
          "github.com/cloudinary/cloudinary-go"
      )
      
      func Concat(cld *cloudinary.Cloudinary) string {
          // Instantiate an object that stores information for asset with public ID "horse_race" in folder "docs/sdk/go"
          v_races, err := cld.Video("docs/sdk/go/horse_race")
          if err != nil {
              fmt.Println("error")
          }
      
          // Add the transformation
          v_races.Transformation = "c_fill,h_300,w_450/du_5/fl_splice,l_video:swimming_race/c_fill,h_300,w_450/du_5/fl_layer_apply"
      
          // Generate and print the delivery URL
          myURL, err := v_races.String()
          fmt.Println(myURL)
          if err != nil {
              fmt.Println("error")
          }
          return myURL
      }

      ✔️ Feedback sent!