Skip to content

Golang Strategy Pattern

April 9, 2014

In Go, functions are first class types. Methods are functions that have a bound receiver that really is the first argument to a function, but I’ll discuss that in a later post. The strategy pattern allows us to write code that performs a certain function and inject different behavior at specific points. Languages that treat functions as first class types make this fairly easy, and I’ve included an example of this in Go below.

Advertisements

From → Golang

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: