> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure the Go SDK (video tutorial)

## Overview

Learn how to install and configure the [Cloudinary Go SDK](go_integration) in your Go environment. This will enable you to utilize Cloudinary for uploading, managing, and displaying assets in your applications.

## Video tutorial

  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.

## Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.### Introduction
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=00 :player=cld} | The [Cloudinary Go SDK](go_integration) gives you a way to handle images and videos at scale, providing transformation, optimization and delivery capabilities that you can integrate seamlessly into your Go applications. 
|

### Install the Go SDK
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=17 :player=cld} | To install the Cloudinary Go SDK, ensure you're in the directory where your Go module was initialized using `go mod init`. Use the `go get` command to add the Cloudinary Go [library](https://github.com/cloudinary/cloudinary-go) from GitHub to your project.
|

```go
go get github.com/cloudinary/cloudinary-go/v2
```

### Configure Cloudinary
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=29 :player=cld} | To configure Cloudinary, begin by creating a Cloudinary instance. Import the Cloudinary library from GitHub and use the `cloudinary.New` function to create the instance. Store this instance in a variable, such as `cld`, and include error handling.
|

my_file.go

```go
import {
    "github.com/cloudinary/cloudinary-go/v2"
}

func main() {
    cld, err := cloudinary.New()
    if err != nil {
        log.Fatalf("failed to initialize Cloudinary client: %v", err)
    }
}
```
### Add credentials
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=48 :player=cld} | To keep your credentials secure:Store them in a `.env` file.Install the library with `go get github.com/joho/godotenv`.Import the `godotenv` library in your code.Use `godotenv.Load()` to load the credentials into your Go file.Retrieve your Cloudinary credentials from the [API Keys](https://console.cloudinary.com/app/settings/api-keys) page in the Cloudinary Console. Copy the provided **API environment variable** format (containing the **Cloud Name**, **API Key**, and **API Secret**) and paste it into your `.env` file, replacing the placeholder values with your actual credentials. 
|

```go
go get github.com/joho/godotenv
```

my_file.go

```go
import {
    "github.com/cloudinary/cloudinary-go/v2"
    "github.com/joho/godotenv"
}

func main() {
    err := godotenv.Load()
    if err != nil {
        log.Fatalf("Error loading .env file: %v", err)
    }
    cld, err := cloudinary.New()
    if err != nil {
        log.Fatalf("failed to initialize Cloudinary client: %v", err)
    }
}
```

### Retrieve an image delivery URL from Cloudinary
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=2 :sec=03 :player=cld} | With your Cloudinary instance configured, you can generate a delivery URL for an image in your product environment: Use the `cld.Image` function with the public ID of the desired image to create an image object. For this example, you can use the public ID of a sample image `cld-sample` provided with every new Cloudinary account. Store this object in a variable named `img` and handle any errors. Convert the image object to a string to generate the delivery URL. Include error handling and print the URL upon success.|

my_file.go

```go
import {
    "github.com/cloudinary/cloudinary-go/v2"
    "github.com/joho/godotenv"
}

func main() {
    err := godotenv.Load()
    if err != nil {
        log.Fatalf("Error loading .env file: %v", err)
    }
    cld, err := cloudinary.New()
    if err != nil {
        log.Fatalf("failed to initialize Cloudinary client: %v", err)
    }

    img, err :=cld.Image("cld-sample")
    if err !=nil {
        fmt.Println("error")
    }

    url, err := img.String()
    if err != nil {
        fmr.Pringln("error")
    } else {
        fmt.Println("Image URL: ", url)
    }
}
```

### Run the code
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=2 :sec=51 :player=cld} | After writing the code, run it to see the delivery URL for the `cld-sample` image. This confirms that your Cloudinary instance was successfully created and used. You can also open the URL in a browser to view the image in your product environment.
|

## Keep learning

> **READING**:
>
> * Learn more about the [Go SDK](go_integration).

> * Watch more [Dev Hints videos](https://www.youtube.com/playlist?list=PL8dVGjLA2oMpaTbvoKCaRNBMQzBUIv7N8) on the [Cloudinary YouTube channel](https://www.youtube.com/cloudinary).

#### If you like this, you might also like...

  
  
  
    Optimization Tips
    Tips for delivering optimized images 
  

  
  
  
    Create Upload Presets (Node.js)
    Streamline media uploads using signed upload presets 
  

  
  
  
    Auto Upload
    Automatically upload remote images and videos to Cloudinary 
  

&nbsp;

&nbsp;Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.
&nbsp;

