Go tool and library for generating code from the template using interface definition.
go get -u github.com/fredipevcin/ifacecodegen/cmd/ifacecodegen
ifacecodegen -source examples/interface.go -destination -
or
cat examples/interface.go | ifacecodegen
Other options
ifacecodegen -h
Example templates and interface are located in examples
folder.
# example 1
ifacecodegen \
-source examples/interface.go \
-template examples/example1.tmpl \
-destination - \
-meta service=account \
-imports "opentracing=github.com/opentracing/opentracing-go,tracinglog=github.com/opentracing/opentracing-go/log"
# example 2
ifacecodegen \
-source examples/interface.go \
-template examples/example2.tmpl \
-destination -
Inspired by: