go-interfaces

Extension Contract (4 parts)

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "go-interfaces" with this command: npx skills add lookatitude/beluga-ai/lookatitude-beluga-ai-go-interfaces

Go Interface Design

Extension Contract (4 parts)

  1. Interface (small, 1-4 methods)

type ChatModel interface { Generate(ctx context.Context, msgs []schema.Message, opts ...GenerateOption) (*schema.AIMessage, error) Stream(ctx context.Context, msgs []schema.Message, opts ...GenerateOption) iter.Seq2[schema.StreamChunk, error] BindTools(tools []tool.Tool) ChatModel ModelID() string }

  1. Hooks (all fields optional, nil = skip)

type Hooks struct { BeforeGenerate func(ctx context.Context, msgs []schema.Message) (context.Context, []schema.Message, error) AfterGenerate func(ctx context.Context, resp *schema.AIMessage, err error) (schema.AIMessage, error) OnError func(ctx context.Context, err error) error } func ComposeHooks(hooks ...Hooks) Hooks { / chain: each receives output of previous */ }

  1. Middleware: func(T) T

type Middleware func(ChatModel) ChatModel func ApplyMiddleware(model ChatModel, mws ...Middleware) ChatModel { for i := len(mws) - 1; i >= 0; i-- { model = mwsi } return model }

  1. Registry

See go-framework skill.

Rules

  • Accept interfaces, return structs.

  • If interface > 4 methods, split it.

  • Optional capabilities via type assertion: if br, ok := r.(BatchRetriever); ok { ... }

  • Embed for composition: type MyAgent struct { agent.BaseAgent; ... }

  • Hook naming: Before<Action> (modify input), After<Action> (modify output), On<Event> (observe/modify).

  • Middleware applies first (outermost), hooks fire within execution.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

streaming-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

go-framework

No summary provided by upstream source.

Repository SourceNeeds Review
General

doc-writing

No summary provided by upstream source.

Repository SourceNeeds Review
General

provider-implementation

No summary provided by upstream source.

Repository SourceNeeds Review