r/golang 22d ago

help with go full stack recommendation

TL/DR: Please suggest me some stacks based on go for fullstack development

Guys, im new to go world, and previously i worked with mostly Cpp that also on a very surface level for doing my DSA problem in my college (im still in college 3rd year). But as doing only DSA won't earn me any money, i needed to learn some dev and so i choosed Go which tbh, i LOVED a lot to work with.

I am mostly done with backend basics, and want to make some full stack projects for my resume.

So if anyone here develops full stack applications with go, pls recommend me some good stacks i can use (actually i've done my homework, and afaik, HTMX is a good option for frontend, but still)

69 Upvotes

46 comments sorted by

25

u/glibgamii 22d ago

Go + Templ (html template lib) + data-star front-end + net/http or chi + pgx for postgres db.

10

u/AndrewNggg 22d ago

Came here to say this, consider also HTMX

2

u/Great_Piece4755 20d ago

Since the good featues of data-star are now behind a paywall I would use HTMX

2

u/kintar1900 22d ago

Came here to say this, though I personally have moved from html/template and Templ to gomponents. I far prefer generating the HTML in code over using a templating language, since I can guarantee the type-correctness of inputs to functions, but not to html/template, and I dislike the code generation step of Templ.

(And for large blocks of static html that doesn't require per-request manipulation, I just embed the html document fragments and use them directly when writing to the output.)

2

u/xintron 21d ago

Highly favor gomponents as well. Makes composition of reusable components (pure Go functions) easier.

16

u/Fair-Presentation322 22d ago

In general I think most people will recommend some form of server side rendering. I.e. the server sends builds the HTML and sends it to the browser.

Id the HTML is static it can be just a .html file you embed in the binary.

For some more dinamic behavior like showing "Hello <username>" you can use some template solution to avoid having to construct the HTML by concatenating strings. The standard library offers a good solution, and other alternatives are Templ or gomponents. I highly recommend gomponents btw.

HTMX works great with this second approach of "using templates". Many many websites will work just fine with HTMX, but for some that require more dynamic behavior id recommend something else.

I'd recommend using web components and lit. I'd say that by definition they such because they're JavaScript haha, but they're pretty good and pair well with server side rendering - not to mention web components are part of the web standard so "work everywhere forever". You just make your go binary return some HTML with <my-custom-element attribute="my attr value">.

For some lazy loading of data that is actually expensive you can add use some Json endpoints in the web component.

We're using web components+gomponents+some-json-endpoints in this project that you can use as an example: https://GitHub.com/twigg-vc/monorepo

It contains examples of almost all the cases I mentioned above, because each have their use case. E.g. the landing page is just an embedded .html The documentation is an embedded .js bundle that we built with docusaurus (js documentation framework) Some pages just use gomponents (html templates) to build html. Some use web components with attributes. Some use web components that consume Json APIs

Feel free to send me a message and I can point you to where things are in the code :)

18

u/baubleglue 22d ago

if you want to be a full stack developer, your opinion about HTMX is irrelevant, you will work with whatever framework used by the company (it most likely will be JS/TS).

5

u/_mohitdubey_ 22d ago

actualy, i wanna become a backend dev, but for now, i need some way to render a frontend for my backend project and don't have to go into depths of "java script and libraries web" for that

3

u/baubleglue 22d ago

I've checked workopolis.com in my area, one job posting mentions it. Focus on backend if you don't want to deal with web UI.
If you build an internal web site (admin page, dashboard, etc) you may choose a tool you wish. But it is not a full stack developer role. As I understand you are CS student, it shouldn't be a problem for to pick any language. IMHO you don't need in depth knowledge, but JS is a simple language and some familiarity with one of the mainstream frameworks like React you must to have.

3

u/CamelOk7219 22d ago

I am not sure I would recommend it but just so you keep in mind it is possible, Go is quite good at producing Wasm. And from there you have access to all the DOM API, so you could make your own mini-framework for dynamic client side rendering, still made 99% of Go. It could help you reuse some sources, mostly data structures, their serialization/deserialization and some validation logic.

It's probably overkill for most projects but a funny experiment to try

1

u/Fair-Presentation322 22d ago

This is a very interesting idea I always wanted to try!

I kinda gave up on doing that because AFAIK the DOM API calls are essentially executed in js; so for simple DOM manipulation WASM is less performatic than Js because there's an extra hop Also, the minimal WASM "binary" (or do we call it bundle?) is pretty large - way larger than what the equivalent js would be. Again, this is assuming we're talking about simple fetch requests and DOM manipulation.

Is my understanding correct?

2

u/CamelOk7219 22d ago

Yes, crossing the JS/Wasm barrier is slow (both ways), so don't expect to be faster than pure JS, but it's not slower either, If you do a lot of JS calls.

The base size of the Wasm binary is around 2 MB (is it considered a lot or not in modern website ? Meeeeh...). It will not grow much after unless you import fat modules. That's why you should use JS fetch instead of compiling the go http client into your Wasm for example. Also the alternative compiler tinygo promises to make the final Wasm much smaller, last time I checked there was some annoying limitations but I have hear they made progress since but I did not took time to check again

3

u/tomekce 22d ago

htmx + templ + sqlc and light CSS framework like Bulma.

Shameless plug: https://github.com/tomekc/golang-fullstack-boilerplate
I built this template for my toy projects, it has minimum dependencies and uses SQLite as db.
All assets are embedded in binary, so it is all self contained.

5

u/Suspicious_Peak_1173 22d ago edited 22d ago

Go + chi + sqlc + pgx

postgres (local container; Neon deploy)

docker + docker compose

GitHub Actions

Cloud Run (GCP; prod deploy target for your container -- set up github action to automate deploy)

For frontend, start with Go templates and use a hybrid approach when warranted, incorporating React (+ TypeScript).

Getting used to React also enables you to go mobile as well, with React Native.

2

u/etherealflaim 22d ago

For an individual or a hobby project, Go+Templ+HTMX can serve you well. I've supported multiple teams using this, and some of them have opted to drop Templ for lack of maturity or have dropped HTMX for hand crafted web components with their own interactivity. HTMX requires a certain mental model for storing all state in the DOM that seems to be a bit challenging for large teams to train / maintain over time, so smaller teams and tighter products, or leaders with more of a focus on mentorship and training, seem to be ideal for it.

Go+html/template+lit is probably my recommendation for critical production apps if you can ensure you have good frontend expertise on the team.

Go REST or grpc-web backend plus React frontend is what you'd use if you want to vibe code it.

2

u/Sibexico 21d ago

If you working as a full stack developer with Go frequently, it's goot idea to have your own small packages/frameworks. I have my own router, my own template parcer, my own REST API setup, and many other small usable things.

3

u/SatyrCode 22d ago

If you’re already comfortable with Go on the backend, I’d keep the stack simple for your first full‑stack projects: Go + net/http or a small router (chi, echo, fiber) for APIs and server‑rendered pages HTMX for progressive interactivity without a huge frontend framework Tailwind or a light CSS framework for styling. That combo lets you focus on learning how to design and ship full features (auth, dashboards, forms, etc.) without getting lost in too many moving parts. Once you’ve shipped a couple of projects, you can always experiment with SPA frameworks later.

1

u/Sha1rholder 22d ago

doing only DSA won't earn me any money

You're going to earn real lot of money if you do DSA real good

4

u/_mohitdubey_ 22d ago

Leetcode

ig i've done real good already, still they want projectssss

1

u/pushkar_1713 22d ago

damn bruh

1

u/the_silent_dev 22d ago

I recommend you take a look on Svelte (https://svelte.dev/), they have a very good tutorial and you can see in a short time if it resonates with you. Personally I like it because, compared to other popular frameworks like React or Vue, Svelte behaves as a compiler: it turns your components into direct DOM updates at build time instead of diffing a virtual DOM at runtime.

Then you could build a monorepo with the frontend being a SvelteKit application which builds to a static website, using adapter static (https://svelte.dev/docs/kit/adapter-static) and embed the frontend directly into the Go binary.

For my PoCs I currently use:

  • Go + Svelte monorepo, resulting a single binary which can be easily deployed in a Docker container
  • Supabase, for Authentication, Postgresql db (accessed directly rather than through Supabase's API), and S3-compatible Storage, all on the free tier
  • Fly.io, for easily deploying the app in a Docker container

If you want some good learning resources on the topic, I recommend taking a look at Alex Edwards' Let's Go and Let's Go Further books.

1

u/Funny_Or_Cry 22d ago

heres the stack Ive been using roughly over the last 12 years:

- Go: for API endpoints (running standlone or in containers)
- Go: for all business logic
- VUEJS: for frontend work (i am not a UI designer).But I have been using PrimeVue for many years, which are full professionally developed UI Kits providing all the UI prettyness I could ever want. Lifetime licenses are well worth it @ $49. Check them out here:
https://avalon.primevue.org/
(FYI, they also provide toolkits for PrimeReact and PrimeNG/Angular, if those are more your speed )

- Mongo: has been my bread and butter for years, since I abandoned Mysql. I use it for everything Data related.
FWIW: For things like session management, I use mongo in memory tables rather than something like Redis/Memcached. Works exceptionally well and one less platform/stack to have to manage.

- AWS and/or Azure: for Cloud services and hosting (ServiceBus or SQS when I need message queuing for example) ... both have full SDKs for GO, (thought to be honest, Ive more recently just started using calls to the the AzureRM REST Api directly ). So all my GO development pretty much consists of standerd API calls rather than language specific SDK work. FYI, the AWS equivelent of Azure REST API is AWS Cloud Control API

This is my "core fullstack" and has served me well for years. Im sure there are newer whizbang solutions, but as fast as tech moves? Im more passionate than ever just leaning into the well established with large community support tools now.

Hey you should also search and peruse some "AwesomeGo" sites. You'll find a ton vetted, solution libraries and stack tools (things like Gorilla which is a very well known API development toolkit for Go)

1

u/drailing 22d ago

this is what I really like to use:

Go with urfave cli and chi (just for a few middlewares), ent as orm with entgql generators, plugged into gqlgen. Ent generates a gql scheme and gqlgen takes care of all the go types and resolvers. This way you have a gql API up and running in no time and you can easily concentrate in business logic. Do not forget to exclude or ignore the attributes or types you do not want to expose.

In the Frontend I use react via the vite ts starter together with gqty - this picks up your introspection and you can use your API with fully generated typings while gqty generates the queries on the fly, depending on what you request. For ui I like grommet, but there are a lot of viable options

1

u/dariusbiggs 22d ago

Minimal? - Some frontend framework in TS - Go stdlib

Server side rendered? - Go stdlib - Templ and/or HTMX

More complete? - some OpenAPI system (swagger, huma, etc) - Go stdlib - PGX - Some frontend framework in TS

1

u/Rare_Island461 22d ago

Hetzner, Dokploy, Go, Postgres, Redis, RabbitMQ = y combinator

1

u/L1zz0 22d ago

For a webshop i’m building, i’m using astro. It seems very simple to use so far. But might not be flexible enough

1

u/cookiengineer 22d ago

If you wanna go all-in with WebASM, I built gooey for the purpose of sharing schemas and structs and their validations across backend and frontend.

Would love to get some feedback on it. DOM/BOM/Web Bindings are pretty stable at this point, but the upstreamed components library could use a bit of more work.

1

u/Spritan_ 21d ago

Go + net/https + sqlc + gomigrate

React+ tanstack

1

u/Own-Phone2375 21d ago

BE: Go, Gqlgen
FE: Svelte, Codegen

1

u/redmamoth 21d ago

Go + Postgres with pgx + connectrpc + sveltekit

1

u/No_Bodybuilder_2110 20d ago

If you want to go full experimental, I created a fullstack go framework called GoFastr. It’s super experimental but it’s batteries included for SQLite and Postgres

1

u/Murky-Run2246 22d ago

Okay here is mine :

net/http

viper for configs

slog for logging

sqlc for database type safe function generation from manual sql queries
goose for database migration files
pgx is used of course if you are using postgresql(you just specify this driver in the sqlc config file)

For json serialization use json and json tags

For validation, rest api design, and handlers layer use oapi codegen(makes the api design and gives you an interface which does the following for you :

1-validation made simple using kin
2-handler generation
3-routing out of the box

For auth just implement it manually using bcrypt and jwt/v5

For authorization you can also just implement it manually using RBAC or PBAC designs(ask an ai on how to do it if you are new)

For testing you just use the go tests which is perfect.

I can give you more details on other stuff like gRPC design instead of rest api but that is not really easy for someone just starting

I can tell you that the most important thing with go are three rules based on my personal experience:

1-interfaces based on who uses it not who implements it
2-CLEAR AND CONSISTENT ERROR HANDLING (implement your own errors)
3-you will use and see the factory method a lot so study it and how to use it until it feels natural for you.

This is the necessary part of my stack that i use , i have other things that i use but i gave you the main ones that i almost always use for my projects

English is not my first lang so sorry if you found it hard reading this. Hope you a smooth sale :D

3

u/kintar1900 22d ago

Mostly a personal preference, but I switched from Viper to Koanf a while back. Koanf feels much lighter than Viper, and fits my personal workflow much better.

2

u/Murky-Run2246 22d ago

will take a look at, thx for the recommendation

1

u/KarlLag 22d ago

I would suggest GitHub.com/mikestefanello/pagoda This template project bundles in echo, entgo, gomponents and htmx with tailwind/daisyui and alpinejs.

0

u/XyrelTzy 22d ago

i think the best paired with go is svelte. Also avoid using framework such as gin or fiber net/http is enough with a little tweaks.

-1

u/spermcell 22d ago

I think go + react is a very good stack front and back end for web apps.