Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Proxy Pattern 馃帀 #12

Open
wants to merge 1 commit into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to鈥
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -0,0 +1,29 @@
package patterns

import (
"fmt"
)

// Renderer interface
type Renderer interface {
Render()
}

// ReactRenderer struct
type ReactRenderer struct{}

// Render method on ReactRenderer struct
func (rr *ReactRenderer) Render() {
fmt.Println("I am React")
}

// RendererProxy struct
type RendererProxy struct {
renderer Renderer
}

// Render method on RendererProxy struct
func (rp *RendererProxy) Render() {
fmt.Println("I'm checking ya...")
rp.renderer.Render()
}
@@ -0,0 +1,13 @@
package patterns

func ExampleRendererProxy() {
renderProxy := &RendererProxy{
renderer: &ReactRenderer{},
}

renderProxy.Render()

//Ouput:
// I'mchecking ya...
// I am React
}
ProTip! Use n and p to navigate between commits in a pull request.
You can鈥檛 perform that action at this time.