Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

golang and decorators / decorator patterns

NotificationsYou must be signed in to change notification settings

alex-leonhardt/go-decorator-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • a basic function decorator, seeexample1
  • a basic timing decorator (how long does func X take?), seeexample2
  • decorating a method (think OOP), seeexample3
  • another method decorator, but using a Func type, useful when the func signature is rather long, seeexample4
  • method decorator that takes argumentsexample5
  • return the result from the decorated function, instead of printing itexample6
  • a logging decorator, seeexample7
  • a nested decorator example, seeexample8
  • 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 interfaceexample9

contribute

pull requests are welcomed

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp