Structural

Proxy

Provides a surrogate or placeholder for another object.

Lazy loadingAccess controlRemote objects

Understanding Proxy

The Proxy pattern provides a surrogate or placeholder for another object to control access to it. It's useful for lazy loading, access control, logging, caching, and more.

How It Works

Client
Proxy
Cache/Auth/Log
Real Server
Direct access (no control)
1

Direct Access

Client directly accesses the real object.

1 / 4

Basic Implementation

Caching proxy for server requests:

main.go
Loading editor...

Real-World Example: Database Protection Proxy

Access control and audit logging for database queries:

main.go
Loading editor...