Programmable Media

Go quick start

Last updated: Feb-20-2024

This quick start lets you get an end-to-end implementation up and running using the Go SDK in 5 minutes or less.

1. Set up and configure the SDK

Create a go.mod file in the directory where your Go program will be saved:

In a terminal in your Go environment, run the following code:

In a terminal, set your CLOUDINARY_URL environment variable.

Replace CLOUDINARY_URL=cloudinary://API_KEY:API_SECRET@CLOUD_NAME with the API environment variable copied from your product environment credentials:

  • On Mac or Linux:

  • On Windows:

Important
  • 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), the file should be excluded from your version control system, so as not to expose it publicly.

In your project, create a new file called my_file.go. Copy and paste the following into this file:

my_file.go

2. Upload an image

Copy and paste this into my_file.go:

my_file.go (continued)

3. Get and use details of the image

Copy and paste this into my_file.go:

my_file.go (continued)

4. Transform the image

Copy and paste this into my_file.go:

my_file.go (continued)

5. Run your code

Copy and paste this into my_file.go:

my_file.go (continued)

In the terminal, run the following command:

The following original image is uploaded to your Cloudinary account, tagged appropriately and accessible via the URL shown below.

The transformed version of the image is accessible via the URL shown below.

Original image Original image
http://res.cloudinary.com/&ltcloud-name&gt/image/
upload/v1/quickstart_butterfly
Transformed image Transformed image
http://res.cloudinary.com/&ltcloud-name&gt
/image/upload/e_sepia
r_max/v1/quickstart_butterfly

View the completed code

See the code above in action using this code playground.

Note
If you want to see the output:
  • Click Remix to Edit.
  • Copy your API environment variable value (i.e., only the portion after the equal sign, cloudinary://<api_key:api_secret@cloud_name).
  • Paste it into the Glitch .env file as the Variable Value for CLOUDINARY_URL.
  • Click Logs at the bottom of the screen.

This code is also available in GitHub

Next steps

  • Learn more about the Go SDK by visiting the other pages in this SDK guide.
  • Get comprehensive details about Cloudinary features and capabilities:

✔️ Feedback sent!

Rate this page: