Kotlin SDK
Kotlinv1.0.0
Installation
Section titled “Installation”Gradle (Kotlin DSL)
Section titled “Gradle (Kotlin DSL)”dependencies { implementation("gg.flags:flags-kotlin:1.0.0")}Gradle (Groovy)
Section titled “Gradle (Groovy)”dependencies { implementation 'gg.flags:flags-kotlin:1.0.0'}<dependency> <groupId>gg.flags</groupId> <artifactId>flags-kotlin</artifactId> <version>1.0.0</version></dependency>Quick Start
Section titled “Quick Start”import gg.flags.client.FlagsClientimport gg.flags.client.Auth
suspend fun main() { val client = FlagsClient.builder() .auth(Auth( projectId = "your-project-id", agentId = "your-agent-id", environmentId = "your-environment-id" )) .build()
// Check a flag if (client.isEnabled("new-feature")) { println("Feature is enabled!") }
// List all flags val flags = client.getAllFlags() flags.forEach { flag -> println("${flag.details.name}: ${flag.enabled}") }
client.close()}Go-Style API
Section titled “Go-Style API”An alternative API style is also available:
import gg.flags.client.*
val client = FlagsClient.NewClient( WithAuth(Auth( projectId = "your-project-id", agentId = "your-agent-id", environmentId = "your-environment-id" )), WithMemory(),)
if (client.Is("new-feature").Enabled()) { println("Feature is enabled!")}
client.close()