Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

alex-leonhardt/go-decorator-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang and the decorator pattern

a playground for me (and maybe helpful for others?) to train the brain understand the decorator pattern better

  • a basic function decorator, see example1
  • a basic timing decorator (how long does func X take?), see example2
  • decorating a method (think OOP), see example3
  • another method decorator, but using a Func type, useful when the func signature is rather long, see example4
  • method decorator that takes arguments example5
  • return the result from the decorated function, instead of printing it example6
  • a logging decorator, see example7
  • a nested decorator example, see example8
  • passing data to a http handler is a little weird (to me), but a fully working example is here: go-web-random
  • let's play with a interface example9

contribute

pull requests are welcomed