4 ms·
> plain Go How's Go with web applications that render HTML content? I've had a lot of fun building microservices with JSON REST APIs in Go lately, but I have n
by majewsky 9y ago
> plain Go
How's Go with web applications that render HTML content? I've had a lot of fun building microservices with JSON REST APIs in Go lately, but I have not done anything that emits HTML. I'm afraid that as soon as you generate HTML, stuff gets messy and you need to include bajillion modules with all this CSS/JS crap.
- ovao 9y agoIf what you're trying to achieve is to pump out some HTML, Go has built-in safe HTML templating. The template syntax isn't glamorous (in fact it can be very unpleasant at times), but with it you can catch type errors at parse time, and the ability to bind custom functions on your templates comes in handy. Usefully, too, any type that implements the Stringer interface can be dropped into a template and will come out of it as a string without any additional fussing. If your app implements a number of custom types, it's actually possible to get Go templates to look relatively sane.