---
sidebar_label: Go
title: Connect with Go Connector
pagination_next: develop/insert-data
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Initialize Module

```
go mod init tdengine.com/example
```

## Add Dependency

add `driver-go` dependency in `go.mod` .

```go-mod title="go.mod"
module goexample

go 1.17

require github.com/taosdata/driver-go/v2 develop
```

## Config

Run this command in your terminal to save DSN(data source name) as variable:

<Tabs defaultValue="bash">
<TabItem value="bash" label="Bash">

```bash
export TDENGINE_GO_DSN="<goDSN>"
```

</TabItem>
<TabItem value="cmd" label="CMD">

```bash
set TDENGINE_GO_DSN="<goDSN>"
```

</TabItem>
<TabItem value="powershell" label="Powershell">

```powershell
$env:TDENGINE_GO_DSN="<goDSN>"
```

</TabItem>
</Tabs>


<!-- exclude -->
:::note
Replace <goDSN\> with the real value, the format should be `https(<cloud_host>)/?token=<token>`.
To obtain the value of `goDSN`, please log in [TDengine Cloud](https://cloud.tdengine.com) and click "Connector" and then select "Go".

:::
<!-- exclude-end -->

## Connect

Copy code bellow to main.go.

```go title="main.go"
{{#include docs/examples/go/connectexample/main.go}}
```

Then download dependencies by execute command:

```
go mod tidy
```

Finally, test the connection:

```
go run main.go
```