https://github.com/alex-leonhardt/go-decorator-pattern
golang and decorators / decorator patterns
https://github.com/alex-leonhardt/go-decorator-pattern
decorator-pattern golang learn-to-code learning-go learning-golang programming-exercise
Last synced: 3 months ago
JSON representation
golang and decorators / decorator patterns
- Host: GitHub
- URL: https://github.com/alex-leonhardt/go-decorator-pattern
- Owner: alex-leonhardt
- Archived: true
- Created: 2017-08-26T13:20:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-31T22:35:57.000Z (over 7 years ago)
- Last Synced: 2023-11-07T16:55:25.193Z (over 1 year ago)
- Topics: decorator-pattern, golang, learn-to-code, learning-go, learning-golang, programming-exercise
- Language: Go
- Homepage: https://dev.to/ineedale
- Size: 11.7 KB
- Stars: 136
- Watchers: 6
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 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](example1/)
- a basic timing decorator (how long does func X take?), see [example2](example2/)
- decorating a method (think OOP), see [example3](example3/)
- another method decorator, but using a Func type, useful when the func signature is rather long, see [example4](example4/)
- method decorator that takes arguments [example5](example5/)
- return the result from the decorated function, instead of printing it [example6](example6/)
- a logging decorator, see [example7](example7/)
- a nested decorator example, see [example8](example8/)
- passing data to a http handler is a little weird (to me), but a fully working example is here: [go-web-random](https://github.com/alex-leonhardt/go-web-random/blob/master/main.go#L25-L35)
- let's play with a interface [example9](example9/)## contribute
pull requests are welcomed