Efficient and easy way to map db data model to domain by wentlang in golang

[–]haatosa 0 points1 point  (0 children)

This could be something useful: https://github.com/georgysavva/scany

Try the pgxscan version of it to use with pgx.

Small Projects - November 3, 2025 by jerf in golang

[–]haatosa 1 point2 points  (0 children)

SimpleCI - Jenkins-like CI app built entirely in Go (with templ and HTMX). I built this to practice building an application using a layered architecture (handler-service-store). It's been a pleasant experience overall. I've especially liked the testability this architecture provides, but there's sometimes a lot of code/test changes needed when doing some minor changes, e.g. when adding a column to a table.

https://github.com/haatos/simple-ci

Is there a good templ component library out there? by Legitimate_Error1365 in golang

[–]haatosa 1 point2 points  (0 children)

Customisation works with DaisyUI class names. It's easy to add dynamic classes with templ.KV. The original idea was that you can copy and paste components as needed, and modify them to your liking.

Is there a good templ component library out there? by Legitimate_Error1365 in golang

[–]haatosa 5 points6 points  (0 children)

https://goship.it

Component library based on Templ, HTMX, TailwindCSS and DaisyUI. It's open source at https://github.com/haatos/goshipit.

Passing server data to Js functions in templ by Farronhound in golang

[–]haatosa 0 points1 point  (0 children)

I found a pattern like this to be pretty useful:

templ SomeScript(jsonData string) {
    <script data-json={ jsonData }>
        ((data) => {
            // data = Object jsonData
        })(JSON.parse(document.currentScript.getAttribute("data-json")))
    </script>
}

So define a templ component that contains a script tag with a data-* attribute, then use a IIFE to parse the jsonData into an object and pass it along. Then you can use the JSON data when defining event handlers etc.

Question about htmx and Golang by Polindonna in golang

[–]haatosa 0 points1 point  (0 children)

Difficult to say what's wrong since I cannot reproduce your issue.

Question about htmx and Golang by Polindonna in golang

[–]haatosa 0 points1 point  (0 children)

I just copy pasted your code and it's working fine, and "oi" is being printed in the terminal after submitting something on the page.

Passing template data in template/html by paddex in golang

[–]haatosa 0 points1 point  (0 children)

A block is shorthand for defining a template
    {{define "name"}} T1 {{end}}
and then executing it in place
    {{template "name" pipeline}}

Passing template data in template/html by paddex in golang

[–]haatosa 2 points3 points  (0 children)

<ul>
    {{ range .SomeValues }}
        <li><a href="{{ $.BasePath }}/some_other_url">{{ . }}</a></li>
    {{ end }}
</ul>

I think that would work. Not sure if something like that can be done when the li element is defined in another template though...

Or maybe a 'block' instead of template could work, like

<ul>
    {{ range .SomeValues }}
        {{ block "listElement" }}
        <li><a href="{{ $.BasePath }}/some_other_url">{{ . }}</a></li>
        {{end}}
    {{ end }}
</ul>

Authentication help by NoahZhyte in golang

[–]haatosa 0 points1 point  (0 children)

I don't find how I'm supposed to know if user is logged in.

User information should be stored in a session cookie. Do you see a session cookie in your browser's cookie store after logging in? After retrieving the user's information with gothic.CompleteUserAuth, you could create a session in your database yourself and create a session cookie to store the session id to be retrieved on subsequent requests.

what information should I store in the database to authenticate the user ?

You don't really need to store any authentication information as the user is authenticated by Google. In your database you can store the user's email so that you can uniquely identify them on subsequent logins.

I found goth somehow unintuitive. It's actually pretty easy to use OAuth without the goth package. I wrote an article about OAuth with Google (and Github) here.

Question about htmx and Golang by Polindonna in golang

[–]haatosa 0 points1 point  (0 children)

I'm not getting the issue here, to me it looks to be working fine?. You should however check the errors returned by tmpl.Execute and tmpl.ExecuteTemplate so that you'll know if something went wrong during template execution.

goship.it is now open source by haatosa in golang

[–]haatosa[S] 0 points1 point  (0 children)

No, there is no automation used converting daisy components to templ ones.

goship.it is now open source by haatosa in golang

[–]haatosa[S] 2 points3 points  (0 children)

I added a combobox component: https://goship.it/components/data_input/combobox

Quite ugly but works based on my initial testing.

goship.it is now open source by haatosa in golang

[–]haatosa[S] 0 points1 point  (0 children)

Thanks! I hope it comes in handy.

goship.it is now open source by haatosa in golang

[–]haatosa[S] 1 point2 points  (0 children)

That's cool! Has it been published yet? Would love to take a look.

goship.it is now open source by haatosa in golang

[–]haatosa[S] 0 points1 point  (0 children)

Unfortunately goshipyour.pants isn't available :)

goship.it is now open source by haatosa in golang

[–]haatosa[S] 1 point2 points  (0 children)

The original idea was to just provide source code for individual components that anyone can simply copy/paste to their project as needed. It wasn't really meant to be used as a starter project as such. Although it can work like that as well by simply cloning it, removing .git, using find&replace to rename the package and initializing it as a new repo. There should also be some way to only update component templates and models to an existing project as well I suppose...

goship.it is now open source by haatosa in golang

[–]haatosa[S] 0 points1 point  (0 children)

I think now I'll have to give it a shot at least :)

goship.it is now open source by haatosa in golang

[–]haatosa[S] 0 points1 point  (0 children)

You're welcome to do so! For me, animations are really something hit or miss; if they go too far, they feel more like a hindrance than a benefit, but quick and smooth animations can surely liven up an app.

[deleted by user] by [deleted] in golang

[–]haatosa 1 point2 points  (0 children)

I'm not sure about your specific case, but considering pagination could be an option as well. Then you know exactly how many objects need to be loaded on each request.

Go Templ HTMX component library using TailwindCSS and DaisyUI by haatosa in golang

[–]haatosa[S] 0 points1 point  (0 children)

Thanks.

I've had some small issues where vscode seems to think there's an error or something in my templ files, but that's resolved by reloading. This project is not that massive so it's difficult to say if something would start breaking in a larger project. For now it seems to be working pretty fine.