Query features with Chalk's Go client library
The Chalk Go client library provides a convenient way to query features from your Go applications.
Install the Chalk Go client using go get:
go get github.com/chalk-ai/chalk-goHere’s a quick example of how to use the Chalk Go client:
package main
import (
"context"
"fmt"
"log"
"github.com/chalk-ai/chalk-go"
)
func main() {
// Initialize the client
client, err := chalk.NewClient(
chalk.WithClientID("your-client-id"),
chalk.WithClientSecret("your-client-secret"),
chalk.WithEnvironment("your-environment-id"),
)
if err != nil {
log.Fatal(err)
}
// Query features
result, err := client.Query(context.Background(), chalk.QueryParams{
Inputs: map[string]interface{}{
"user.id": "user123",
},
Outputs: []string{
"user.credit_score",
"user.account_age_days",
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result)
}