# Feature Flag Decision

A Feature Flag has an on state and an off state. A different feature is configured for each state.\
When a user accesses a feature that has a Feature Flag applied, the on or off state must be returned. You can perform this state decision through the Hackle SDK.

## IsFeatureOn

By passing a **Feature Key** to the `isFeatureOn()` method, you can receive the state result for the user. Then implement logic based on the state.

In the example code below, Feature Key 42 is passed, and the User Identifier for the user whose state is to be determined is "ae03e1adf".

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

// 기능 키가 42인 기능 플래그에서 사용자의 상태를 결정합니다.
// 결정하지 못하는 상황인 경우 false(꺼짐 상태)를 반환합니다.
user := hackle.NewUserBuilder().ID("ae2182e0").Build()
isFeatureOn := hackleClient.IsFeatureOn(42, user)

if isFeatureOn {
    // ON 기능
} else {
    // OFF 기능
}
```

## FeatureFlagDetail

The `FeatureFlagDetail()` method works the same as the `IsFeatureOn()` method and additionally provides the reason for the state decision. It is useful for checking whether Override is working correctly or when the result ratio seems unusual relative to the configured Traffic Allocation.

You must pass the Feature Key as a parameter. In the example code below, Feature Key 42 is passed.

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

user := hackle.NewUserBuilder().ID("ae2182e0").Build()
decision := hackleClient.FeatureFlagDetail(42, user)

// 기능 on/off 여부
isFeatureOn := decision.IsOn()

// 상태 결정 사유
reason := decision.Reason()
```

The state decision reason is returned in the form of **`SDK_NOT_READY`**. Refer to the table below for details.

<table><thead><tr><th width="233.71875">Decision Reason</th><th width="370.8046875">Description</th><th>Distribution Result</th></tr></thead><tbody><tr><td><code>SDK_NOT_READY</code></td><td>The SDK is not ready to use.<br>(e.g., initialization attempted with an invalid SDK Key)</td><td>Default state<br>(off)</td></tr><tr><td><code>FEATURE_FLAG_NOT_FOUND</code></td><td>No Feature Flag was found for the provided Feature Key.<br>The Feature Key may be incorrect, or the Feature Flag may be archived.</td><td>Default state<br>(off)</td></tr><tr><td><code>FEATURE_FLAG_INACTIVE</code></td><td>The Feature Flag is in the off state.</td><td>Default state<br>(off)</td></tr><tr><td><code>INDIVIDUAL_TARGET_MATCH</code></td><td>Matched by Individual Targeting.</td><td>State configured by<br>Individual Targeting</td></tr><tr><td><code>TARGET_RULE_MATCH</code></td><td>Matched by User Targeting.</td><td>State configured by User Targeting</td></tr><tr><td><code>DEFAULT_RULE</code></td><td>Did not match either Individual Targeting or User Targeting.</td><td>State configured by<br>default rule</td></tr><tr><td><code>EXCEPTION</code></td><td>An unknown error occurred.</td><td>Default state<br>(off)</td></tr></tbody></table>

## Feature Flag Parameter Settings

* You can also receive the parameter values for the state decision through the `FeatureFlagDetail()` method.
* Since parameter values configured on the Hackle Feature Flag screen exist as key-value pairs, you can use the methods below according to the configured parameter type to receive and use the configured parameter value.
* You can dynamically change values on the Feature Flag parameter settings screen.

### GetString

* Returns parameter values configured as STRING or JSON type.

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

user := hackle.NewUserBuilder().ID("ae2182e0").Build()
decision := hackleClient.FeatureFlagDetail(42, user)

stringValue := decision.GetString("string_key", "default_value")
jsonValue := decision.GetString("json_key", "{}")
```

### GetNumber

* Returns the parameter value configured as Number type as a float64 type.

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

user := hackle.NewUserBuilder().ID("ae2182e0").Build()
decision := hackleClient.FeatureFlagDetail(42, user)

numberValue := decision.GetNumber("number_key", 42.0)
```

### GetBool

* Returns parameter values configured as Boolean type.

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

user := hackle.NewUserBuilder().ID("ae2182e0").Build()
decision := hackleClient.FeatureFlagDetail(42, user)

boolValue := decision.GetBool("bool_key", false)
```


---

# 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/go-feature-flag.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.
