# v2 API Go Code Example

> \[!WARNING]
>
> To access all the latest features and upcoming developments, please see our [v3 API](/docs/sendgrid/api-reference). For assistance with transitioning, refer to our [migration guide](/docs/sendgrid/for-developers/migration-guides/v2-to-v3-api).

> \[!NOTE]
>
> We recommend using SendGrid Go, our client library, [available on GitHub](https://github.com/sendgrid/sendgrid-go), with full documentation.

> \[!NOTE]
>
> The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see [Continue Using V2 in Go](https://github.com/sendgrid/sendgrid-go/blob/main/TROUBLESHOOTING.md#v2).

## Using SendGrid's Go Library

```go
// using SendGrid's Go Library
// https://github.com/sendgrid/sendgrid-go
package main

import (
    "github.com/sendgrid/sendgrid-go"
)

func main() {
    sg := sendgrid.NewSendGridClientWithApiKey("SENDGRID_APIKEY")

    message := sendgrid.NewMail()
    message.AddTo("test@sendgrid.com")
    message.SetFrom("you@example.com")
    message.SetSubject("Sending with SendGrid is Fun")
    message.SetHTML("and easy to do anywhere, even with Go")

    sg.Send(message)
}
```
