go-patterns
esc

កាតាឡុក

លំនាំ Go ទាំងអស់

តម្រៀបតាមរបៀបដែលវិស្វករត្រូវការ៖ តាមបញ្ហាដែលនៅពីមុខអ្នក មិនមែនតាមជំពូកដែលវាមកពី។

31 ក្នុង 31
Abstract Factory Create related objects through one factory so whole product families can change together without leaking concrete types. មិនទាន់អាន Builder Separate a multi-step construction workflow from the final representation so the same input can produce different outputs cleanly. មិនទាន់អាន លំនាំ Factory Method ក្នុង Go ប្រើ constructor functions និង interfaces តូចៗ ដើម្បីជ្រើស concrete implementations ដោយមិនភ្ជាប់ callers ទៅនឹងវា។ មិនទាន់អាន លំនាំ Prototype ក្នុង Go ចម្លង object graphs ដែលបានកំណត់រួច នៅពេលការចម្លងសាមញ្ញ ឬលឿនជាងការសាងសង់ឡើងវិញពីដើម។ មិនទាន់អាន លំនាំ Singleton ក្នុង Go ប្រើ sync.Once ដោយប្រុងប្រយ័ត្នសម្រាប់ការចាប់ផ្តើមតែម្តង ហើយយល់ថាពេលណា dependency injection ជាជម្រើសល្អជាង។ មិនទាន់អាន Adapter Wrap an incompatible API behind the interface your application already expects so the rest of the code stays unchanged. មិនទាន់អាន Bridge Separate an abstraction from its implementation so both sides can vary independently without multiplying concrete types. មិនទាន់អាន Composite Treat individual objects and object groups uniformly so recursive tree structures stay simple to traverse and aggregate. មិនទាន់អាន Decorator Add behavior around an object dynamically by wrapping it with small focused layers that share the same interface. មិនទាន់អាន Facade Provide one simplified entry point over several collaborating subsystems so callers can trigger a workflow without knowing every step. មិនទាន់អាន Flyweight Share intrinsic immutable state across many small objects so large collections stay cheaper in memory and easier to manage. មិនទាន់អាន Proxy Control access to another object by standing in front of it to add caching, authorization, rate limiting, or lazy loading. មិនទាន់អាន លំនាំ Chain of Responsibility ក្នុង Go បង្កើត validation និង request-processing pipelines ដោយប្រើ handlers តូចៗដែលត្រូវបានផ្សំតាម interfaces។ មិនទាន់អាន លំនាំ Command ក្នុង Go ខ្ចប់ operations សម្រាប់ queuing, audit history និង undo/redo ខណៈដែលរក្សា Go error handling ឱ្យច្បាស់លាស់។ មិនទាន់អាន Interpreter Define a small grammar for recurring business rules and evaluate sentences of that grammar with an expression tree. មិនទាន់អាន Iterator Traverse a collection without exposing its internal representation, keeping traversal state separate from the aggregate. មិនទាន់អាន Mediator Centralize communication between collaborating objects so they depend on a coordinator instead of referencing each other directly. មិនទាន់អាន Memento Capture and restore object state without exposing internal details so undo and rollback remain explicit and controlled. មិនទាន់អាន Observer Notify dependent subscribers when state changes so event-driven reactions stay decoupled from the publisher. មិនទាន់អាន State Change an object’s behavior when its internal state changes by delegating transitions and rules to state-specific types. មិនទាន់អាន Strategy Encapsulate interchangeable algorithms behind one interface so callers can swap behavior without branching on concrete rules. មិនទាន់អាន Template Method Define the skeleton of an algorithm once while letting concrete steps vary through narrow hook methods. មិនទាន់អាន Visitor Add operations across a stable object structure without changing each node type whenever a new operation is introduced. មិនទាន់អាន Agent Loop (ReAct) Drive an agent by alternating reasoning and acting steps inside a structured loop that terminates when the model signals a final answer. មិនទាន់អាន Tool Use Register typed tools by name so an agent can dispatch LLM-selected function calls to the right handler without embedding dispatch logic in the agent itself. មិនទាន់អាន Orchestrator-Subagent Decompose a complex task by having a root agent spawn and coordinate specialized subagents, each responsible for one concern, then aggregate their results. មិនទាន់អាន Memory Give an agent a pluggable memory store — short-term context buffer, episodic session history, and optional long-term semantic store — through one interface so the storage backend can be swapped. មិនទាន់អាន Retrieval-Augmented Generation Ground LLM responses in authoritative documents by retrieving relevant chunks before generation so the model can cite real data instead of hallucinating. មិនទាន់អាន Human-in-the-Loop Pause agent execution at defined checkpoints to request human approval or input, then resume with the human's decision injected back into the agent's context. មិនទាន់អាន Prompt Template Build prompts from versioned, parameterized templates so prompt logic stays separate from agent orchestration code and can be tested, diffed, and swapped independently. មិនទាន់អាន Multi-Agent Communication Enable agents to exchange typed messages through a shared message bus so they can collaborate without direct references to each other's implementations. មិនទាន់អាន