TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Gomponents, HTML components in pure Go

113 pointsby markusw7 months ago
Hey everyone! I just released v1.0.0 of gomponents last week. It's an HTML component builder in pure Go, with a DSL-like HTML syntax. It's been 4 years in the making, and makes it really easy to build HTML in your web apps.

12 comments

markusw7 months ago
Hey all! Sorry for being late to the party. I posted this on HN earlier this week, and only just saw it pop up here. I&#x27;ll hang around today and try to answer questions and comments. :) I&#x27;m in the CEST timezone.<p>You may also be interested in the &quot;go podcast()&quot; episode I was in earlier this week, talking about gomponents with Dominik: <a href="https:&#x2F;&#x2F;gopodcast.dev&#x2F;episodes&#x2F;045-gomponent-with-markus-wustenberg" rel="nofollow">https:&#x2F;&#x2F;gopodcast.dev&#x2F;episodes&#x2F;045-gomponent-with-markus-wus...</a>
icy7 months ago
Similarly, for Templ&#x2F;Tailwind&#x2F;AlpineJS components, I’ve recently found <a href="https:&#x2F;&#x2F;goilerplate.com" rel="nofollow">https:&#x2F;&#x2F;goilerplate.com</a>.
评论 #41876884 未加载
flashgordon7 months ago
So I like the idea of it but am feeling a bit wary about UI elements as runtime types. Good thing about this is the strong typing but then you have a fair bit of lispifying going on which I swing back and forth on. I actually like templ&#x27;s approach on this (though hate the extra build step). So I finally just settled on plain old go templates. Not quite eloquent but just feels staple and simple. Clearly a lot of get off my lawn type of biases here :)
评论 #41875439 未加载
floydnoel7 months ago
are event handlers possible? neither the Github repo nor the linked page showed an example of a button or form submission.
评论 #41876441 未加载
评论 #41875298 未加载
评论 #41876492 未加载
评论 #41875243 未加载
评论 #41856116 未加载
hn60007 months ago
This reminds me of Lucky Framework for Crystal<p><a href="https:&#x2F;&#x2F;luckyframework.org&#x2F;guides&#x2F;frontend&#x2F;rendering-html" rel="nofollow">https:&#x2F;&#x2F;luckyframework.org&#x2F;guides&#x2F;frontend&#x2F;rendering-html</a>
ramiborni997 months ago
I just learned Golang, and i liked your idea, i&#x27;m going to test it soon! saved in bookmarks
评论 #41901804 未加载
cynicalsecurity7 months ago
This is a horrifyigly bad idea.
评论 #41881315 未加载
评论 #41877900 未加载
评论 #41880053 未加载
dgraph_advocate7 months ago
Awesome, now do it in Haskell!
评论 #41874891 未加载
评论 #41876641 未加载
burntcaramel7 months ago
That’s awesome! I have a very similar project Dovetail, that tries to nudge you into making things accessible.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;RoyalIcing&#x2F;Dovetail">https:&#x2F;&#x2F;github.com&#x2F;RoyalIcing&#x2F;Dovetail</a>
评论 #41876501 未加载
评论 #41875748 未加载
burgerrito7 months ago
Looks cool. There is also Templ[1] that does something similar, though uses codegen.<p>I wish there is an equivalent of Storybook for these things though, it would be really nice!<p>[1] <a href="https:&#x2F;&#x2F;templ.guide&#x2F;" rel="nofollow">https:&#x2F;&#x2F;templ.guide&#x2F;</a>
评论 #41876498 未加载
评论 #41875751 未加载
jerf7 months ago
While acknowledging the use case of &quot;the designer who doesn&#x27;t know how to program&quot; and the desirability in some sense of separating logic from data, if I am going to slam together some HTML as a programmer, with no &quot;non-programmer&quot; designer in sight, I tend to slap together a local version of templates like this if I can&#x27;t find a good one available. The reason is, if I&#x27;m going to mix logic and presentation anyhow, why bother with a template library that is basically an inner-platform, when I can just use the programming language itself? Then you get other integrations as useful, e.g., do you have some concept of interfaces&#x2F;traits&#x2F;whatever? Define a useful default representation for something and you can push it straight out in a template. This may not work for large UI elements, but in terms of &quot;hey, here&#x27;s how you display a Username in general&quot; it can be useful, and it&#x27;s not like you&#x27;re stuck with <i>only</i> that way of rendering an object.<p>Closures, modules, functions, loops or recursion, conditionals, every feature of your programming language just right there, without some large templating library in the way. Debug your templates with the actual debugger. Very high performance with just a bit of care in the API design. Every programmer in your language can pick this up very quickly with hardly any effort and doesn&#x27;t have to learn yet another complete templating language to start using your project, it&#x27;s just comparable to picking up an API.<p>So many advantages... it&#x27;s just... you <i>have</i> to be programmer if you want to modify the resulting code. Other than that, and I guess the fact you need to implement whatever discipline you may want on your own[1]... but those are a total killer in many cases.<p>[1]: This approach does not <i>require</i> that you mix presentation and logic, but if you want that separation, you will need to discipline yourself to maintain it. Though I have to admit, 25 years of programming on the web and I&#x27;m frankly still unconvinced by this argument, or, at least, unconvinced that it is the absolute most important thing in every context and only a cretinous lunatic would <i>dare</i> mix logic and presentation. It seems to me to be a rule espoused by far more people than it is followed by.
评论 #41876635 未加载
评论 #41880747 未加载
评论 #41875746 未加载
kubb7 months ago
I saw the dot imports and thought “What a neat feature! I wonder why nobody uses it.” Then I googled it and saw a million articles saying how they should be avoided and removed from the language because they make code more difficult to understand.<p>Typical gophers, can’t accept that there’s a time and place for everything and need to have a hard rule to use that applies to every single situation. Imagine that code, but with gomponents.Ul, gomponents.Li, gomponents.Div everywhere.
评论 #41880180 未加载
评论 #41880321 未加载
评论 #41878351 未加载
评论 #41878272 未加载