Live data from Hacker News

Show HN: Use Go's HTML/template to write React-like code

news.ycombinator.com

21–30 of 96 posts

Re: Show HN: Use Go's HTML/template to write React-like code

#21

Although I don’t know Go programming language, I do appreciate people making stuff using as minimal dependencies as possible. I’m glad that I’m not the only one who has this habit.

Thanks! Go makes it really easy to go minimal dependencies.

I was able to build a website analytics project with just 2 dependencies (sqlite driver and bcrypt package) - https://github.com/sheshbabu/mouji?tab=readme-ov-file#philos...

Re: Show HN: Use Go's HTML/template to write React-like code

#22
post #19

I am not a Go or frontend person, so I am a bit confused. I cannot figure out where any necessary JS is generated. The documentation for html/template only says it generated HTM, and a React alternative is presumably producing dynamic frontends (otherwise why would you be using react?). Am I missing something huge?

I apologize for the confusion. I meant React for component composition in codebase rather than for building SPAs.

https://news.ycombinator.com/item?id=40491188

Re: Show HN: Use Go's HTML/template to write React-like code

#24
My style for building web app. I was never convinced that doing everything on JS layer is a good thing (regardless the backend language).

But you need to show more interactivity to convince the JS people.

I personally like this style and add HTMX for partial updates.

Re: Show HN: Use Go's HTML/template to write React-like code

#26
I'm not a full-time Gopher but I had a similar thought a few weeks ago, this idea of just having template partials for components and maybe a function constructor. Templ has a similar feeling but you can get most of what you want with pure Go. In Ruby-world there's the ViewComponent pattern/lib that Github came up with, a sort of HTML non-JS component, but I just can't really see why you need more than simple functions to do it.

Haven't thought it all the way through, I expected the code to come out a little bit cleaner but Go being a bit more explicit is for the better, not much one can do here.

But it's a valid idea: 80% of JS component libraries are just reimplementing "" as "" with no added value atop the HTML.

Re: Show HN: Use Go's HTML/template to write React-like code

#27
A bit off-topic, and maybe it was just an example made without too much thought put into it, but I've noticed there seems to be a lot of people now who write button/links like this:

    My Button
As far as I know that's technically invalid HTML. You can't have an as a child of a (or even the other way around.) I'm also ignoring the invalid type="submit" against the tag in the example button component in the post.

I think it stems from people who want their links to take on the default button styling, but I'm not 100% sure. Has anyone else noticed this trend at all?

Re: Show HN: Use Go's HTML/template to write React-like code

#30
post #27

A bit off-topic, and maybe it was just an example made without too much thought put into it, but I've noticed there seems to be a lot of people now who write button/links like this: My Button As far as I know that's technically invalid HTML. You can't have an as a child of a (or even the other way around.) I'm also ignoring the invalid type="submit" against the tag in the example button component in the post. I think…

Maybe this works on IE6 or something like that?
Post reply on HN