Skip to main content

Get the Reddit app

Scan this QR code to download the app now
Or check it out in the app stores
mstef9 u/mstef9 avatar

mstef9

u/mstef9

New
Open sort options
Change post view

r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Pagoda v0.16.0: Rapid, easy, full-stack web dev starter kit (now w/ SQLite, HTMX 2, and more)

mstef9
replied to zulrang

Definitely worse. Django has been developed for 18 years and has over 2,500 contributors. I'm not even sure if I'm at triple-digit hours yet. It's also a framework whereas this isn't, so you can't completely compare them. The basis of this project was to avoid mega-frameworks in favor of stitching together libraries and remaining very flexible.

What do you use if you want to build a full-stack web app in Go?




Pagoda v0.16.0: Rapid, easy, full-stack web dev starter kit (now w/ SQLite, HTMX 2, and more)
r/golang icon
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
Pagoda v0.16.0: Rapid, easy, full-stack web dev starter kit (now w/ SQLite, HTMX 2, and more)
show & tell

I shared Pagoda, a rapid, full-stack web development starter kit, here almost 3 years ago and it was pretty well received. I've been since maintaining it and continually trying to improve things with the aim of making things as easy to use and extend as possible. I've made a lot of significant changes since sharing so I thought it was time to post again.

The biggest and most impactful was switching to SQLite and removing Postgres and Redis (along with Docker) as a default. It's still very easy to bring those in, but since simplicity and rapid development is key, SQLite seems like the best starting point and is probably sufficient for a large majority of apps (especially any being built with this).

A quick overview of major changes:

  • Switch to SQLite rather than Postgres for storage

  • Switch to SQLite rather than Redis for background task queues

  • Switch to an in-memory cache rather than Redis, with added cache-tag support

  • Upgrade to HTMX 2

  • Much simplified and streamlined form processing and validation

  • Switch from individual routes to grouped handlers with automatic router registration and dependency injection

  • Task processors are now type-safe

  • Switched to viper for easy configuration management

  • Improved package organization

  • Switch to log/slog from the Echo logger and provided a simple structure to use the logger of your choice across the entire application

  • Added a redirect package for easy HTTP redirects

  • And more...

If you found this project useful either for your own development, learning or anything else, please let me know. And if you have any feedback, questions, suggestion, etc, please let me know here, open an issue or PR, or find me on the Gophers slack.

Two questions:

  1. For those of you using Templ, how has your experience been? I like the problems that the project is trying to solve but I haven't really tried it in depth yet. I also feel like the template rendering approach and page functionality in Pagoda has been easy enough to work with (so far).

  2. I default to Bulma for CSS since it provides a ton of ready-to-use components and you don't need any build/tools to use it. Plus there's no JS dependency. Any suggestions for alternatives to consider? I like Tabler but it requires Bootstrap 5 and extra JS.

Thanks


Batcher: Type-safe, automatic, asynchronous batch processing
r/golang icon
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
Batcher: Type-safe, automatic, asynchronous batch processing
show & tell

Sharing a small. simple library that I thought could be useful to others. This was born out of some personal needs (optionally grouping and batch processing incoming PubSub messages being one example). Batcher provides a type-safe, easy way to batch together arbitrary groups of items to be automatically and asynchronously processed. The README contains more information and clear examples.

If you find it useful or have any feedback, please let me know.

Repo: https://github.com/mikestefanello/batcher


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Announcing Atlas Migration Execution Engine | atlasgo.io

mstef9
commented

Awesome work with this and Ent. I've been keeping an eye on Atlas. I've only used it through Ent so far, and it's incredibly impressive. I'm beginning to evaluate it to handle our PG migrations which we're currently doing somewhat manually with not much success.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to aodegard

It's not, but I've been thinking about it. I may experiment with it in a different branch of a different repo. I'm not sure if everyone would want hooks included or baked in to Pagoda, but I do think it would be a very good fit. I recently worked on and published an application example using hooks and do (for DI) to emphasize a fully modular architecture: https://github.com/mikestefanello/hooks-example. That highlights the vision I had for the overall approach with hooks, and I think it came out quite nice. I'd really like feedback on that, so if you have any, please let me know.


Modular monolithic codebase architecture example using Hooks and Do (for DI)
r/golang icon
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
Modular monolithic codebase architecture example using Hooks and Do (for DI)

Last week I posted here about a new library that I released called hooks that was generally well-received. I've since built out an example application using hooks and do (excellent library for dependency-injection) to not only highlight use-cases for hooks but also to demonstrate the larger idea/concept I had for using hooks to build modular monoliths with Go that I wanted to share and perhaps start a discussion about.

Repo: https://github.com/mikestefanello/hooks-example

The readme is quite extensive and the code is condensed and easy to quickly understand. I quite like how this pattern turned out and wanted to hear from the community what they thought about this approach for developing modular monolithic applications. There are certainly downsides, as noted in the readme.

Let me know what you think. Thanks.

(credit to u/samuelberthe for creating do, and many other great libraries)


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to paul_lorenz

I did come across that project and didn't like the use of interface{}. If you think it has some functionality that could be useful in hooks, let me know.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to redales123456

There's two problems with using channels for something like this. You would need the listeners to be constantly running each in separate goroutines to be able to await channel messages as opposed to just registering func callbacks and invoking them when needed. And with channels, if you have N listeners, only 1 will receive each given message, whereas with hooks, you want all of the registered listeners to be invoked.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
commented

Sure. I see it making sense in most/many cases to write something like this yourself so you have full control over it. I didn't write it in hopes that it would be mass-adopted. Just had the idea and wanted to work on it and share it. Maybe it's a good starting point for the custom code you'd write in your app.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
commented

Yes, I did forget to push that. Will do now. Thanks.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to _a8m_

Thanks - and thank you for Ent as well. I do like the middleware concept. That's what I first thought to do for these hooks since it's a similar pattern. A key difference, and one that I'm thinking about for this project, is whether or not a hook should be able to terminate execution for all other hooks (ie, returning an error or invoking the next callback). I think in Ent's case it makes sense to have it the way it is, because the only implementer of a given entity's hook is the entity's schema itself - so if it errors, the operation overall should stop. I can make either case for general purpose hooks. I didn't want them to return errors to avoid coupling and having to check and handle errors when dispatching a hook but there are cases in where I would want that. For example, for a entity/model operation (ie, user insert), it would be nice if the insert hook passed along the DB transaction, and hook listeners could execute their queries on that transaction (ie some other entity gets created when a user is created). But, you can't really do that without returning and handling hook errors.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to TrolliestTroll

That's a very well thought out explanation and it's completely understandable. Thanks for taking the time to elaborate.

We can quibble on whether or not a handler should return an error in Go, but then we have to decide about the semantics of dispatching a handler asynchronously which I’ll leave as an exercise for the reader.

It's a good point and one that I'm a bit stuck on right now. I had the idea to use hooks to transmit the DB transaction used to perform some operation (ie, user insert) so that the listeners could include their queries, but you'd have to not only facilitate errors being returned, you'd also want to, in this case, stop execution if any of them fails, and that sort of pattern begins to defeat the purpose of hooks quite a bit.




r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to thebugswillbite

That looks interesting but I think it's quite different since it uses channels and always-running goroutines to listen rather than explicit callbacks. But the overall concept looks similar.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to rotemtam

Hey. I'm a huge fan of Ent. I think it's an amazing project. Thank you for your work on it. I do know about the hooks and I have used them before. I looked at the implementation while working on this. Like you said, it does rely on code-generation and I wanted something a bit more flexible. The other slight downside of Ent's hooks is that you can only implement them in the model's schema, rather than anywhere, which is what I was aiming for.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Hooks: Simple, type-safe hook system for Go

mstef9
replied to ar1819

Thanks. Event bus usually refers to a completely asynchronous, distributed architecture/system - like a message queue. This is more like lifecycle hooks for various components in a single codebase/process.

https://en.wikipedia.org/wiki/Hooking


Hooks: Simple, type-safe hook system for Go
r/golang icon
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
Hooks: Simple, type-safe hook system for Go

I quickly threw together this package to provide type-safe hooks and was curious if anyone would find something like this interesting. I wasn't able to find anything similar that was type-safe. I've spent a lot of time developing with frameworks that used hooks heavily to provide the ability to modularize your code as much as possible, especially within monoliths, and it's a pattern I've always liked.

Repo: https://github.com/mikestefanello/hooks

If you find this interesting/useful or have any feedback, let me know.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How are you building your web app ?

mstef9
replied to myringotomy

Alpine is really great at providing an easy-to-implement interactive UI. While it does have some support for making server-side requests, libraries like HTMX are a million times better for this. They are often combined and for good reason. What framework is "just for alpine"? I'm not sure what you would do on the backend that would ever be alpine-specific, other than providing templates that contain alpine tags. HTMX doesn't even really require much (and is completely backend-agnostic), but Pagoda does provide an integration to make it easier to read/set request/response headers, handle partial-template rendering, template switching, etc, as well as a handful of examples.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How are you building your web app ?

mstef9
replied to myringotomy

It wouldn't take more than a few minutes to swap Bulma out for anything. It was chosen since it provides a robust library of pre-built components for very easy styling.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

[deleted by user]

mstef9
commented

You may be interested in pagoda (I'm the author) which is a starter-kit for rapid, easy full-stack web development in Go, built upon Echo (web framework) and Ent (ORM). It should give you pretty much everything you'd need right out of the box.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How are you building your web app ?

mstef9
replied to Rtransat

What other companies are doing shouldn't really matter or dictate how you (or your company) approach building something. The application itself, the requirements, your team and resources, etc, should be the determining factors. The 2020 Go survey showed 45% of Go devs were doing SSR HTML. This is the preferred approach for a majority of what is built at mine and would be what I would use for any personal or side projects unless I had a significant reason why it wouldn't work.


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How are you building your web app ?

mstef9
commented

Check out pagoda - you may find it interesting/useful. It's a starter kit for full-stack web development in Go that I've been working on. It aims to provide just about everything you'd need for a web app, show that Go SSR templates can be versatile and powerful, and that libraries such as HTMX and Alpine can allow you to build modern UIs with little or no JS at all.


mstef9 u/mstef9 avatar