The Go HTML builder

Like at the beginning we said, That we don't use interpreted template language (eg go html/template) to generate html page. We think they are:

  • error prone without static type enforcing
  • hard to refactor
  • difficult to abstract out to component
  • yet another tedious syntax to learn
  • not flexible to use helper functions

We like to use standard Go code. the library htmlgo is just for that.

Although Go can't do flexible builder syntax like Kotlin does, But it can also do quite well.

Consider the following code:

It's basically assembled what Kotlin can do, Also is legitimate Go code.