# Go

## Add Dependency

[![](https://img.shields.io/github/v/release/hackle-io/hackle-go-sdk)](https://pkg.go.dev/github.com/hackle-io/hackle-go-sdk)

Add the SDK dependency.

```shell
go get github.com/hackle-io/hackle-go-sdk
```

## SDK Initialization

{% hint style="danger" %}
`hackle.Client` must be a singleton.

`HackleClient` manages state internally to distribute users to Variations immediately without network calls.\
This uses additional resources for that purpose.

Do not instantiate a new client for every request; instead, manage it as a single instance throughout the application lifecycle.
{% endhint %}

`hackle.Client` is the class that provides methods for using SDK features.

To use the SDK, you need to initialize `hackle.Client`.

#### Instantiation

Instantiate `hackle.Client` by passing the SDK Key.\
`hackle.Client` periodically synchronizes with the Hackle server as a background task to obtain the necessary information.

* You can find the SDK Key in [SDK Integration Info](https://dashboard.hackle.io/config/sdk-setting) located inside the Hackle Service Dashboard.

```go
import "github.com/hackle-io/hackle-go-sdk/hackle"

// YOUR_SERVER_SDK_KEY 자리에 SDK 키를 넣습니다.
hackleClient := hackle.NewClient(YOUR_SERVER_SDK_KEY, nil)
```

## Shutdown

You must call the `close()` method when the application shuts down.\
This releases resources in use and sends any remaining events.

{% hint style="danger" %}
If the application shuts down without calling `close()`, events may be lost.
{% endhint %}

```go
import "github.com/hackle-io/hackle-go-sdk/hackle"

hackleClient.Close()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hackle.io/en/development-guide/go.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
