Skip to content

Instantly share code, notes, and snippets.

View pieterlouw's full-sized avatar

Pieter Louw pieterlouw

  • Johannesburg, South Africa
View GitHub Profile
@pieterlouw
pieterlouw / notificationExampleExplanation.md
Last active February 9, 2017 12:38
How interfaces can better your design by using a notification system as an example

In this example we look at a notification system that can send notifications as an sms and email.

Let's have a look at the main function:

func main() {

	//create smsNotifier object
	var smsSender smsNotifier
	smsSender.initialize("the-sms-api-config-details")
@pieterlouw
pieterlouw / repo_example2.md
Created January 18, 2017 20:36
2nd Example for my Go talk on interfaces

##Example 2##

In this example we will look at a part of a web application that manages stock items. The decision was made to start with using an embedded database, something like SQLite or BoltDB, with the idea to scale out to a more distributed database like Cassandra as the business scale.

Let's define the domain type:

package domain

Example 3: 3rd party library/API

In this example we call out to a 3rd party library/API to handle payments.

Let's see the request and response types:

type TransactionRequest struct {
	//request fields
}
/* This is a snippet to show how to add CORS middleware for grpc-gateway implementation */
package main
// all relevant imports here
func main() {
ctx := BackgroundWithSignals()