5 ms·
Started using Go for my latest project (a successor to Evernote). It feels like such a relief, especially having just come out of a node.js project. It's everyt
by dejawu 11y ago
Started using Go for my latest project (a successor to Evernote). It feels like such a relief, especially having just come out of a node.js project. It's everything I wanted in a (web-app) programming language, and for the first time I can say that a language has actually made my code better. I've never had a codebase this clean before.
- thebouv 11y agoI 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.
- cubano 11y agoI don't mean to be snarky and I'm definitely showing my age here, but isn't that exactly what devs were saying about node.js two years ago?
- blub 11y agoIt's what devs are saying about any tech that's becoming popular. It's much more useful to read a competent critique of Go (of which there are a couple) than post after post saying how everything is great. Everything can't be great, it's a basic fact of software engineering!
- boomzilla 11y agoYes, every language/framework is good at something and bad at some other. They are just tools. What matters is what one builds. A lot of technical news these days are about tools, not products.
- cubano 11y agoSure, I can run with that analogy. So a master woodcarver works with chisels, his "tools", for his entire life...30 years, and with them he turns bare wood into incredible works that the world recognizes as valuable art. Someone hands him a chainsaw, which by all measurable metrics should allow him to do the work 10x faster because, of course, it is more powerful, modern, and designed by "superior minds" whom understand IC engines, gearing, etc etc. Does it? And should he switch?
- pcunite 11y agoI think what I want for Christmas is a language with C syntax and keywords, no header files, no GC, ships with a library that has everything (threads, http, websockts, crypto). This new language takes all the bad parts of C and throws them away and does not care about backwards capability. Call this new language C++ or whatever.
- i507244 11y agoYes, of course. Chainsaws are an ideal tool for large scale wood carving. https://www.youtube.com/watch?v=tPJ9t3jIBjA https://www.youtube.com/watch?v=tPJ9t3jIBjA