A decorator implementation
Our decorator pattern example will be runnable, so we'll put it in the main
package and define a main()
function.
We use the easy-metrics package for recording and displaying our metrics. It comes out of the box with a nice GUI for displaying statistics.
We also import the decorator package and preface that import with a dot (.) in order to access the identifiers in the decorator package, in the local file block without a qualifier.
The main.go file
Let's have a look at the contents of main.go
:
package main import ( "crypto/tls" "flag" "fmt" "io/ioutil" "log" "net/http" "net/url" "os" "os/signal" "time" "easy_metrics" . "decorator" ) const ( host = "127.0.0.1" protocol = "http://" ) var ( serverUrl string proxyUrl string )
Note
This is what the imports looked like before using the init script and its aliases (and glide):import (
. . .
"time"
"github.com/l3x/fp-in-go/chapter5/02_decorator/easy_metrics"
. "github.com/l3x/fp...