Godec is decorator fabricator. Godec will automatically create a decorator for desired interface using desired template. The desired template must be placed in folder template/.
go install github.com/bukalapak/godec/app/godec
-
Add
go:generate
hook in desired file//go:generate godec MyInterface canceler type MyInterface interface { Sample(int, string) (float64, error) }
godec needs two or more arguments to run correctly.
godec [interface name] [decorator name]...
[interface name] is the name of interface to be decorated. In the example above, interface's name is
MyInterface
. [decorator name] is the name of decorator. In the example above, decorator's name iscanceler
. Please, note that desired decorator must be placed in template/ folder. Godec will find the desired template there. The name of the template decorator must be<name>.go.tmpl
. Please, look at template/ for clarity. -
Run
go generate
go generate
Decorator will be created in folder
decorator/
.