4 ms·
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 avo
by kubb 2y 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.
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.
- markusw 2y agoYeah, the dot import made the whole thing click for this library. It’s the only use case I found for it so far though. :D Fun fact: I got the idea from an episode of the GoTimeFM podcast, where the hosts and guests were discussing features they would like to see removed from the language.
- arccy 2y agothe import is html not gomponents, which imo is fine
- ofrzeta 2y agoIt's the same with the Ginkgo testing library: "After the package books_test declaration we import the ginkgo and gomega packages into the test's top-level namespace by performing a . dot-import. Since Ginkgo and Gomega are DSLs this makes the tests more natural to read." https://onsi.github.io/ginkgo/ https://onsi.github.io/ginkgo/
- js2 2y ago> (Some people don't like dot-imports, and luckily it's completely optional.) You can rename imports to whatever you like, but the default name for the package that contains the HTML elements is `html`, not `gocomponents`.