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.