Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: What GO web framework do you use?
26 points by umen on July 21, 2022 | hide | past | favorite | 24 comments
Hello HN , what to use to be fast and easy like java's tomcat server ? So many half baked or not maintained frameworks... What do I use in production?



I use the standard library. My entire business runs on it, html/css all through the standard library (templates package).

I use embed to embed all assets in the binary itself. "go build" and then "scp" the binary to the production server and "systemctl restart appserver"


Love that you do this. I have a few enterprise projects that do exactly the same thing (minus the embed in one, just scp and untar). Can’t beat the simplicity.

Regarding the original question we use fiber.io for a few systems and have loved it’s capabilities and performance.


> templates package

How do you like the template package ? Can you compare it to Jinja/Twig ?


I have never used Jinja/Twig, but I have used handlebars, ERB, JSX and other similar templating systems.

Overall, I find Go's template system to be a bit clunky but it certainly gets the job done. The template system is fairly minimal so it feels mostly like working with HTML, but it gives you a few tools to use.. mainly passing data down the template/sub-templates and the ability to define template functions/helpers. Minimal... but it's all you really need.

I converted my business from Rails 5 to Go about a year ago and the ERB was fairly straight forward to convert to Go's template system.. it felt like I was mostly converting <% .. %> to {{ .. }} and changing <%= render ... %> to {{ template ... }}


Thanks, I guess I should try the standard lib before anything else then.


What about scheduled jobs (cron), email notifications, database etc?


My server's binary is more than a server, it can execute one off tasks, etc. For example I can execute the server binary with special arguments, ex "server --task admin-reports" in a cron job.

For the database I use Postgresql with the standard library's database/sql package (using lib/pq as the driver).

For scheduled emails and tasks, I store them in Postgres and I have a task that is run through my server binary every few hours (ex: "server --task scheduled-tasks").


I use Fiber [0] in production for a $4M ARR company and never had any issues even at peak traffic.

Took less than a month to start with and integrate and it is a joy to use.

[0] https://github.com/gofiber/fiber


Same experience for several internal systems. Fiber is amazing.


Mind share what company?


For simple, battle-tested web server, you can't go wrong with net/http.

A couple of us are working on Bud (http://github.com/livebud/bud), which aims to be a full-stack web framework for Go, similar to Laravel or Rails.

The project is getting better very quickly! If you're working on a greenfield project and want more out of the box, I'd encourage you to give Bud a try!


Just stared it! I use Go at work and it’s a joy but I’m currently Lea Laravel because it makes getting something out so easy! I’m was blown away yesterday when I learned how to handle file uploads in laravel, and Breeze allows me to have out of the box user auth in about 5 mins?

I’ve built all of that in Go and it was probably two months of work…

This is not to discourage you, it would be absolutely terrific to have a proper full-stack framework in Go! And just as an aside from what I see in laravel, if making part of the framework commercial is a way to give the project a boost I think it’d be worth it!

Tailwind also comes to mind following the same model. Full open source but if you want a working starter template, payments, teams, subscriptions, etc… I’d pay for that!


looks cool!


net/http. Go has great web support in the standard library.^1

Kidding aside, I didn't think that full-fledged web frameworks (akin to Ruby-on-Rails, Flask, Spring, etc) were really a thing with Go - or at least not a super popular thing. And you should be able to pretty easily recreate the functionality of a Tomcat-like web server using the http/net library.^2

[1]: https://pkg.go.dev/net/http [2]: https://go.dev/doc/articles/wiki/


We've got a mix of a few but are recommending use of https://github.com/gorilla/mux due to it using the net/http interfaces and types, great performance and some configurability which can be handy.

In particular, my team is using it in conjunction with generated code https://deliveroo.engineering/2022/06/27/openapi-design-firs...



I've been using echo for years. Has a great balance of adding helpful utilities while also not imposing bad patterns.


I have used Gin in the past and have really liked it.


you can use standard library unlike other langauages golang has built in support for db[1], timer to schedule tasks[2], emails[3], templates[4] etc. and your application would be fairly upgrade proof. If you insist on using framework you can use echo or gofiber. There is also pockebase.io it uses echo internally but comes with user management etc. built in.

[1] https://pkg.go.dev/database/sql [2] https://pkg.go.dev/time [3] https://pkg.go.dev/net/smtp [4] https://pkg.go.dev/text/template [3]


Why do most Go framework websites look like they were made by uni students for their side projects?

https://gin-gonic.com/

https://echo.labstack.com/

https://gobuffalo.io/

Compare that to Laravel for example: https://laravel.com/


engineering design, not design design


1.7 MB for the echo landing page, 3 MB for laravel landing page. I think that's why


Gin


In production?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: