go-template icon indicating copy to clipboard operation
go-template copied to clipboard

go/template v2

Open brumhard opened this issue 2 years ago • 1 comments

go/template v2

So after around 1,5 years of using go/template we see some room for improvement in several parts.

context

  • the project started out as a opinionated internal template
  • after open source we tried to transition to a less opinionated and more generic template and therefore minimized the folder structure etc.

Anyways, go-template currently only supports one embedded template as the source of truth and we found out that this can't support all the different requirements that arise in different projects, e.g. switching out the build tool etc or supporting a new technology. Also there has always been this conflict between providing too much and needing to delete a lot or too few to really be relevant.

stuff that the new template engine should support

  • every feature of the old engine
  • earthly -> one file additionally replacing e.g. make
  • shared files like gitignores
  • specific library quickstarts e.g. ent
  • technology specifics like gRPC
  • prometheus, instrumentation
  • database implementation postgres
  • dummy business logic
  • CLI vs server/backend
  • completely different project architecture like pulumi provider template

envisioned/possible solutions

  • modular system (maybe gRPC plugin based like terraform/pulumi)
  • modules provide specific functionality, the exact scope will have to be defined
  • modules/plugins can be opinionated, the go-template itself should be fairly generic
  • it might be necessary that plugins have dependencies to other modules, and also to edit existing files
  • users can define what modules they want to use
  • some modules will be embedded/vendored with go-template but the system allows others to write their own modules

brumhard avatar May 12 '23 12:05 brumhard

@linuxluigi already started a draft for this module system at https://github.com/SchwarzIT/go-template/pull/254. I also created an interface that I will try to implement.

brumhard avatar May 12 '23 12:05 brumhard