Go (Server) — SDK detail
- Official docs: Go SDK reference
- API reference:
LDClient,MakeClient - Recipe (detect / install): SDK Recipes (Go Server)
The Initialize the client chapter shows MakeClient / MakeCustomClient (and optional ldcontext + NewScopedClient for a scoped client). It does not use Initialized() in that section. The error from MakeClient is what signals construction-time failure (see the “Best practices for error handling” callout in those docs). If you need to branch on “fully ready” after the timeout window, use Initialized or Monitoring SDK status—read MakeClient for how the timeout interacts with returning before the client has finished connecting.
Includes: Minimal onboarding sample aligned with “Go SDK, using LDClient and default configuration” in the docs. For MakeCustomClient, ldcontext, LDScopedClient, or the observability plugin, follow the same page’s larger examples.
package main
import (
"fmt"
"os"
"time"
ld "github.com/launchdarkly/go-server-sdk/v7"
)
func main() {
ldClient, err := ld.MakeClient(os.Getenv("LAUNCHDARKLY_SDK_KEY"), 5*time.Second)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create LaunchDarkly client: %v\n", err)
os.Exit(1)
}
fmt.Println("LaunchDarkly client created.")
// For onboarding purposes only we flush events as soon as
// possible so we quickly detect your connection.
// You don't have to do this in practice because events are automatically flushed.
ldClient.Flush()
}