--- sidebar_label: Go title: Connect with Go Connector description: Connect to TDengine cloud service using Go connector --- 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" {{#include docs/examples/go/connectexample/go.mod}} ``` ## Config Run this command in your terminal to save DSN(data source name) as variable: ```bash export TDENGINE_GO_DSN="" ``` ```bash set TDENGINE_GO_DSN= ``` ```powershell $env:TDENGINE_GO_DSN='' ``` :::note Replace with the real value, the format should be `https()/?token=`. To obtain the value of `goDSN`, please log in [TDengine Cloud](https://cloud.tdengine.com) and click "Programming" on the left menu, then select "Go". ::: ## 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 ``` The client connection is then established. For how to write data and query data, please refer to [Data In](https://docs.tdengine.com/cloud/data-in/) and [Data Out](https://docs.tdengine.com/cloud/data-out/). For more details about how to write or query data via REST API, please check [REST API](https://docs.tdengine.com/cloud/programming/connector/rest-api/).