golang curl api

package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    // Step 1: Define the API endpoint URL
    apiURL := "https://example.com/api"

    // Step 2: Create an HTTP client
    client := http.Client{}

    // Step 3: Create an HTTP request
    request, err := http.NewRequest("GET", apiURL, nil)
    if err != nil {
        fmt.Println("Error creating request:", err)
        return
    }

    // Step 4: Set any required headers
    request.Header.Set("Content-Type", "application/json")
    request.Header.Set("Authorization", "Bearer YourAccessToken")

    // Step 5: Send the HTTP request
    response, err := client.Do(request)
    if err != nil {
        fmt.Println("Error sending request:", err)
        return
    }
    defer response.Body.Close()

    // Step 6: Read the response body
    body, err := ioutil.ReadAll(response.Body)
    if err != nil {
        fmt.Println("Error reading response body:", err)
        return
    }

    // Step 7: Print the response body
    fmt.Println("Response Body:", string(body))
}