Instead, if you build on the standard library, you can compose your application from there- a good muxer, some standard middleware that are generic http.Handler's, a session library, etc.
Go in Production – Lessons Learned
11–20 of 109 posts
Re: Go in Production – Lessons Learned
#12This article has almost nothing to do with Go in particular. Just...general stuff to follow when writing code. What is it here that talks specific things about "Go" + "in production"?
Re: Go in Production – Lessons Learned
#13If this wasn't on the front page of HN I'd have stopped reading here, but it is, so I didn't, then I regretted it.
Re: Go in Production – Lessons Learned
#14Re: Go in Production – Lessons Learned
#15> silently handling panics That has a bad smell
Especially since caught panics amount to exceptions and most Golang code isn't exception safe. It's a recipe for leaking database connections, deadlocks, etc.
In go, if you write code like the following:
conn, err := db.Connect()
defer conn.Close()
That defer will be run during a panic. Same thing as 'defer mutex.Unlock()'Yes, like most of go, it's manual and painful and poorly thought out, but most people do follow these patterns, so for the most part go code will safely unwind from a panic.
Re: Go in Production – Lessons Learned
#16Earlier quoted context omitted.
What path to this enlightenment would you recommend to one who has cut his teeth and delivered many projects (over many years) in Rails/Django?
This is a side effect of go’s lack of meta programming to be honest. So much magic that is possible in rails/django/etc is just not possible in golang. This leads to go web frameworks being sort of semi-hard mountainous turds of code generation. You’ll want to stick to stdlib after sifting through them and deciding they aren’t worth it.
Re: Go in Production – Lessons Learned
#17Re: Go in Production – Lessons Learned
#18* go-chi/chi
* rs/zerolog
* html/template
* spf13/viper
* raw SQL
Re: Go in Production – Lessons Learned
#19Why would you want to serve a 200 with an error message in a JSON response body?
The other one is http status codes are http status codes. As in the http request was done correctly, but the application code wasn't. More specifically, http layer was executed successfully, but the application layer was not.
Re: Go in Production – Lessons Learned
#20You almost certainly don't need a web framework. Over the long term, it's easy to find yourself boxed in with how opinionated many of them are. Instead, if you build on the standard library, you can compose your application from there- a good muxer, some standard middleware that are generic http.Handler's, a session library, etc.
Or, and bear with me here, you can outsource those decisions to other folks, and just write your business logic.