Go SDK
Last updated: Dec-01-2025
The Cloudinary Go SDK provides simple, yet comprehensive image and video upload, transformation, optimization, and delivery capabilities through the Cloudinary APIs, that you can implement using code that integrates seamlessly with your existing Go application.
How would you like to learn?
| Resource | Description |
|---|---|
| Go quick start | Get up and running in five minutes with a walk through of installation, configuration, upload, management and transformations. |
| Video tutorials | Watch tutorials relevant to your use cases, from getting started with the Go SDK, to uploading, transforming and analyzing your images and videos. |
| Sample projects | Explore sample projects to see how to implement Cloudinary functionality such as upload and delivery with transformations. |
| Cloudinary Go SDK GitHub repo | Explore the source code and see the CHANGELOG for details on all new features and fixes from previous versions. |
Install
Cloudinary's Go integration library is available as an open-source package.
Create a go.mod file in the directory where your Go program will be saved:
To install the library, run:
Update
To update the Cloudinary Go SDK to the latest version, use the go get command with the -u option:
Migrating to versions 2.x
When migrating from versions 1.x to 2.x, note the following changes:
- Include
/v2in the path when importing Cloudinary libraries, for example:github.com/cloudinary/cloudinary-go/v2/api/admin. - Parameters that were of type
boolare now of type*booland must be passed as pointers to boolean variables. You can use theapi.Bool(true)andapi.Bool(false)helper methods to pass the desired values. - Some parameter names have changed. Specifically:
- Instances of
Idsin parameter names are nowIDs. For example, thePublicIdsparameter of theDownloadZipURLmethod is nowPublicIDs. - Instances of
Urlin parameter names are nowURL. For example,PrivateDownloadUrlis nowPrivateDownloadURL. - Instances of
Apiin parameter names are nowAPI.
- Instances of
Configure
Import the required packages for upload and admin:
Set required configuration parameters
For requests to our secure APIs (e.g., image uploads, asset management) you must have the APIKey and APISecret parameters set. You can find your product environment configuration credentials in the API Keys page of the Cloudinary Console Settings.
Setting your CloudName, APIKey and APISecret parameters can be done by initializing the Cloudinary object, or by using the CLOUDINARY_URL environment variable.
To define the CLOUDINARY_URL environment variable:
- Copy the API environment variable format from the API Keys page of the Cloudinary Console Settings.
- Replace
<api_key>and<api_secret>with your actual values. Your cloud name is already correctly included in the format.
For example:
The entry point of the library is the Cloudinary struct. Here's an example of setting up your configuration using your API environment variable:
Alternatively, you can pass your CloudName, APIKey and APISecret as parameters:
Or initialize a new Cloudinary instance (if you've already set the environment variable):
- When writing your own applications, follow your organization's policy on storing secrets and don't expose your API secret.
- If you use a method that involves writing your environment variable to a file (e.g.
dotenv), exclude the file from your version control system, so as not to expose it publicly.
Set additional configuration parameters
In addition to the required configuration parameters, you can define a number of optional configuration parameters if relevant.
You can append configuration parameters, for example upload_prefix and secure_distribution, to the environment variable:
Or use the NewFromURL method:
Or you can set them by accessing the Config struct fields (using PascalCase field names):
urlAnalytics configuration option. Learn more.
Configuration video tutorial
Watch this video tutorial to see how to install and configure the Go SDK:
This video is brought to you by Cloudinary's video player - embed your own!
Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.
Use
Once you've installed and configured the Go SDK, you can use it for:
- Uploading files to your product environment: You can upload any files, not only images and videos, set your own naming conventions and overwrite policies, moderate and tag your assets on upload, and much more. See example
- Transforming and optimizing images and videos: Keeping your original assets intact in your product environment, you can deliver different versions of your media - different sizes, formats, with effects and overlays, customized for your needs. See example
- Managing assets: Using methods from the Admin and Upload APIs, you can organize your assets, for example, list, rename and delete them, add tags and metadata and use advanced search capabilities. See example
Quick example: File upload
The following Go code uploads the dog.mp4 video using the PublicID, my_dog. The video overwrites the existing my_dog video if it exists. When the video upload finishes, the specified notification URL receives details about the uploaded media asset.
- Read the Upload guide to learn more about customizing uploads, using upload presets and more.
- See more examples of image and video upload using the Cloudinary Go library.
- Explore the Upload API reference to see all available methods and options.
Quick example: Transform and optimize
Take a look at the following transformation code and the image it delivers:
In the Go SDK, transformations are applied by passing the transformation string directly to the Transformation parameter. The transformation string uses the same syntax as the Transformation URL API, with individual transformations separated by commas and transformation chains separated by forward slashes.
This relatively simple transformation string performs all of the following on the original front_face.jpg image before delivering it:
- Crop to a 150x150 thumbnail using face-detection gravity to automatically determine the location for the crop
- Round the corners with a 20 pixel radius
- Apply a sepia effect
- Overlay the Cloudinary logo on the southeast corner of the image (with a slight offset). Scale the logo overlay down to a 50 pixel width, with increased brightness and partial transparency (opacity = 60%).
- Rotate the resulting image (including the overlay) by 10 degrees
- Optimize the image to reduce the size of the image without impacting visual quality.
- Convert and deliver the image in PNG format (the originally uploaded image was a JPG)
And here's the URL that's generated:
In a similar way, you can transform a video.
- Read the Transform and customize assets guide to learn about the different ways to transform your assets.
- See more examples of media transformations using the Cloudinary Go library.
- See all possible transformations in the Transformation URL API reference.
Quick example: Get details of a single asset
The following Go example uses the Admin API Asset method to return details of the image with PublicID cld-sample:
Sample output:
- Check out the Manage and analyze assets guide for all the different capabilities.
- Get an overview of asset management using the Go SDK.
- Select the Go tab in the Admin API and Upload API references to see example code snippets.
Sample projects
Take a look at the Go sample projects page to help you get started integrating Cloudinary into your Go application.
- Try out the Go SDK using the quick start.
- Learn more about uploading images and videos using the Go SDK.
- See examples of media transformations using Go code, and see our image transformations and video transformation docs.
- Check out Cloudinary's asset management capabilities, for example, renaming and deleting assets, adding tags and metadata to assets, and searching for assets.
- Stay tuned for updates by following the Release Notes and the Cloudinary Blog.