> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/go.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
