6 ms·
Gadget: A smallish web framework for Go
- acron0 13y agoLooks smart! Curiously, any reason you chose not to use Revel?
- redneckbeard 13y agoTwo reasons: 1) I didn't want routes in a text file. This is whiny, I know. Just a personal preference. 2) Go is the only programming language that has held my attention long enough to actually finish a fairly usable framework. Writing a framework is a good exercise in software design, so I felt like I had to use the opportunity.
- acron0 13y agoI totally agree with you on routes in a text file. Are you gonna go 'batteries included' with Gadget, or keep aiming for that middle ground? I ask because I am looking to put my weight behind a framework and am undecided, but not at all attracted to Revel...
- redneckbeard 13y agoI would like to go something like "batteries included but not installed." The User interface I have now is a good example of what I mean -- I would prefer to keep everything built around implementing an interface, but it might be nice to provide an "official" authentication implementation as a subpackage. I've started writing subpackages as they become important to me. The most useful thus far is probably gadget/forms, which is very much inspired by Django forms. I prefer a data validation layer that is independent from or at least very loosely coupled to a model layer.
- ds_ 13y agoOr martini? I liked the look of martini but have not delved deep enough to make an informed decision. Might pick Go for my next side project...
- saiko-chriskun 13y agoJust came back from a go meetup where I met the developer of martini actually, I think it's a really well thought-out framework :)
- mmgutz 13y agoThe only thing I really see in martini over plain gorilla mux is dependency injection which has a reflection cost. Once you peel back the Classic mode, which I advise not using except for trivial projects, your code base is about the same. I'm sticking with gorilla.
- keda 13y agoUnlike Revel, you don't seem to have watch setup for .go files, which make sense since you want to keep it smallish. Curious on how other gopher trigger app restart from their editor of choice. Anyone have insight for setting up VIM+Tmux for Golang development that enable app restart from single key press? Sample .vimrc will be great.
- altf4 13y agoI use Grunt [1] and (especially) grunt-contrib-watch [2] for this. Using Grunt also has the benefit of automatically recompiling CSS files and/or concatenating JS files etc. But your mileage may vary, of course. [1] http://gruntjs.com/ http://gruntjs.com/ [2] https://github.com/gruntjs/grunt-contrib-watch https://github.com/gruntjs/grunt-contrib-watch
- codegangsta 13y agoI totally built a watcher command line app and ditched it because this was more convenient :) https://github.com/codegangsta/dotfiles/blob/master/vim/vim/ftplugin/go.vim#L4 https://github.com/codegangsta/dotfiles/blob/master/vim/vim/...
- redneckbeard 13y agoRecompiling and restarting the server has yet to become a bottleneck in development for me, or at least it hasn't caused enough friction or irritation to compel me to add something using fsnotify or other solutions. If you told me that you were very interested in using the framework but the lack of this feature was a barrier to adoption, I'd definitely think harder about it.
- RBerenguel 13y agoI write plain handlefuncs, but so far I have a pretty easy to remember command to restart the server for local development (works as well in Acme, where I'm writing most of my go code as in emacs, where I write templates and vim, where I usually just make really quick edits.) It's Cmd-Tab C-c [up] enter. Just trying to express the same redneckbeard said: until it is a very thin bottleneck, this should be no problem.
- bwooceli 13y agoAs a "non programmer" this excites me greatly. I learned Python by way of Django and can't wait to stand on some Go giant shoulders.
- voidlogic 13y agoI would love to hear why I would want something like this, or revel, or goweb, over: angular.js + Go web-service (net/http + Gorilla).
- redneckbeard 13y agoI just don't understand the argument that we should all just use HandlerFuncs for everything. Python and Ruby have stdlib HTTP facilities that are pretty good. They aren't nearly as nice as net/http, but you could totally build websites with them. People still have written lots of web frameworks, because it makes their lives easier. It lets them express programs in a simpler, higher-level way. I feel like this is even more valid now in 2013 since nearly anyone who's building websites has done so with one of those high-level frameworks, and they expect a similar experience. Lots of people have abandoned Rails for Sinatra, or Django for Flask. That's totally cool, and there are good reasons to do so. There are also very good and obvious reasons to use something that further abstractions common patterns if the software you are building conforms reasonably well to those patterns.
- voidlogic 13y ago> feel like this is even more valid now in 2013 since nearly anyone who's building websites has done so with one of those high-level frameworks, and they expect a similar experience. But in 2013 do I really want to use server side HTML tempalating? Why not just connect a webservice to a HTML/JS presentation layer like I am suggesting? If all you are doing is building a webservice then the abstractions beyond net/http + Gorilla are not buying you much IMHO, but they do come at quite a performance cost: http://www.techempower.com/benchmarks/#section=data-r7&hw=i7&test=json&l=cn4 http://www.techempower.com/benchmarks/#section=data-r7&hw=i7... My first couple Go web applications did things the html/template way and were structured on the way I used to go JSF applications- but since I switched to the above approach my projects have been better performing, faster to develop , better scaling and easier to maintain. As we all know, we seldom get all those things in one technology choice without trade-offs.
- recuter 13y ago
- bernatfp 13y agoAs a fan of Flask/Bottle/Sinatra/Express style web frameworks I miss a Go framework that works in a similar fashion. Don't know of any better way to prototype APIs so quickly and with such a small mental effort. Edit: Just discovered [Martini](https://github.com/codegangsta/martini https://github.com/codegangsta/martini), that's exactly what I wanted.
- codegangsta 13y agoHave you seen Martini? https://github.com/codegangsta/martini https://github.com/codegangsta/martini
- bernatfp 13y agoYeah just after posting my comment. BTW, great work, that's exactly what I was looking for.
- recuter 13y agoI'm kind of amazed at the SLOC, ~600 lines for the whole thing. Flask is much bigger and depends on Werkzeug (~20K?), heck even Bottle doesn't come in under 1,000 lines. That is incredibly attractive.
- codegangsta 13y agoYup I plan to keep it that way too. I believe there is enough flexibility in Martini to cultivate some great functionality around the martini-contrib repo. There is already some pretty awesome things landing there https://github.com/codegangsta/martini-contrib https://github.com/codegangsta/martini-contrib
- krakensden 13y agobottle.py might be a better Python comparison, since they're more concerned about being small & standalone.
- draegtun 13y agoCheckout Camping (Ruby) & Squatting (Perl). Both are web microframeworks that aim (when minimised) to fit at or under 4K characters. Here's the squashed versions of... - Camping (currently 4.031 kb over 55 lines) - https://github.com/camping/camping/blob/master/lib/camping.rb https://github.com/camping/camping/blob/master/lib/camping.r... - Squatting (currently 3.929 kb over 68 lines) - https://github.com/beppu/squatting/blob/master/lib/squatting.pl https://github.com/beppu/squatting/blob/master/lib/squatting...
- re-l 13y agoDamn, routers and controllers are not an issue in Go, models — is. I belive, that rich middleware between rich backend and rich client does matter. It isn't manipulating with html views, it's working with data. It's a proxy layer. And unfortunately, I don't see it in the modern Go web frameworks. Anyway, it's a great job.
- elithrar 13y agoYou could easily use something like gorp (https://github.com/coopernurse/gorp https://github.com/coopernurse/gorp) alongside Gadget (or any other Go web framework). Like Flask, the use of SQLAlchemy isn't innately tied to the framework.
- kin 13y agoThis is an irrelevant comment but I love the name. I'm assuming it's a play on the Go-Go-Gadget line?