3 ms·
I understand the basics of Go, but do you have any advice on where to start using it for web app development? Any framework that you're using (if one at all)?
by thebouv 11y ago
I understand the basics of Go, but do you have any advice on where to start using it for web app development? Any framework that you're using (if one at all)?
- lsllc 11y agoI've used go-martini on a number of projects; it strikes a nice balance between performance (it's by no means the fastest Go web framework) and usability.
- dejawu 11y agoI've picked out the following that I like: - Gorp[1] for SQL stuff (I like that it "encourages" your program data structure to reflect your DB structure) - amber[2] for templating - gorilla/mux[3] for routing - gorilla/securecookie[4] for login/auth management (they have a sessions and context library too if you want that) Go also has libraries that handle basic versions of most of these tasks (and these third-party libraries extend them). If you're building something simple they might be sufficient. [1] https://github.com/go-gorp/gorp https://github.com/go-gorp/gorp [2] https://github.com/eknkc/amber/ https://github.com/eknkc/amber/ [3] http://www.gorillatoolkit.org/pkg/mux http://www.gorillatoolkit.org/pkg/mux [4] http://www.gorillatoolkit.org/pkg/securecookie http://www.gorillatoolkit.org/pkg/securecookie
- deepanchor 11y agoI've found the standard library to be more than capable for most CRUD style apps. You can add in simple middleware chaining using a library such as Alice (https://github.com/justinas/alice https://github.com/justinas/alice) and for passing around request contexts between them, you can use something like xhandler (https://github.com/rs/xhandler https://github.com/rs/xhandler). If you want more performant or flexible routing, httprouter (https://github.com/julienschmidt/httprouter https://github.com/julienschmidt/httprouter) has a nice feature set. Maybe it's personal preference, but there's something more satisfying about the modular approach of building up an app using only components I need and understand, rather than starting with a magical feature-laden framework but quickly realizing you don't need half of what it does. I think Go aligns particularly well with this philosophy given its emphasis on composition.
- lobster_johnson 11y agoThat's the libraries I use, too. I really wish contexts were built into Go's HTTP library. Without contexts, you have to use global variables to accomplish things like per-request logging and access to configuration data. Not to mention that since goroutines cannot be forcibly terminated, it's the only way to control the lifetime of a handler (e.g. applying timeouts).
- pkates 11y agoYou may be looking for https://godoc.org/golang.org/x/net/context https://godoc.org/golang.org/x/net/context which is likely to make it into stdlib in the 1.7 timeframe from what I've seen in various channels. Doesn't quite solve the global logging problem though.
- lobster_johnson 11y agoYep, that's the context we (I and the grandparent comment) are using.