Skip to content

Go SDK ​

高性能 Go SDK,用于连接 Croupier Agent、注册函数并处理调用。

代码位置 ​

  • sdks/go

特性 ​

  • 与 monorepo 中的 proto/** 保持演进一致
  • 支持函数描述符、会话管理与错误处理
  • 适合服务端高并发集成
  • 呈现 hints 便捷层(x-ui-* 契约,见 呈现 Hints 契约):
go
metadata, _ := function.NewMetadataBuilder().
    SetID("player.ban").
    SetInputSchema(`{"type":"object","properties":{"id":{"type":"string"}}}`).
    SetFieldWidget("id", "Select").
    SetFieldHint("id", "x-options-source", map[string]interface{}{
        "functionId": "player.list",
        "labelPath":  "/items/*/name",
        "valuePath":  "/items/*/id",
    }).
    Build()

安装 ​

bash
go get github.com/cuihairu/croupier/sdks/go

快速开始 ​

go
package main

import "github.com/cuihairu/croupier/sdks/go/pkg/croupier"

func main() {
	cfg := &croupier.ClientConfig{
        AgentAddr: "127.0.0.1:19091",
		GameID:    "my-game",
		Env:       "development",
	}
	_ = croupier.NewClient(cfg)
}

继续阅读 ​