News for hackers. Stuff that matters.
Re:Show HN: Getting started with Go and Martini by Zikes on Monday April 27, 2015 @11:11AM (#9446772)
The original developer's thoughts on Martini: http://codegangsta.io/blog/2014/05/19/my-thoughts-on-martini...

Personally, I would like to highlight the part about Martini not being idiomatic. Being idiomatic in Go is a fairly big deal. It makes your code predictable and easier to read and maintain for other Go developers, and learning idiomatic practices can help a Go developer more easily pick up other Go frameworks and libraries.

That's really the only concern I would have about using Martini to "get started" with Go, as it would actually lead you down a wholly different direction from the rest of the community and may actually make learning Go more difficult for a new developer.

As an alternative, I would recommend the wonderful Go By Example: http://gobyexample.com/

Re:Show HN: Getting started with Go and Martini by gtrubetskoy on Monday April 27, 2015 @11:23AM (#9446866)
I've been watching the Go "web framework" scene over the past year, and more and more I'm inclined to think that the Rails/Django/Sinatra paradigm simply isn't going to work with Go and pursuing it is futile. There is an interesting article on why ORM (ORM's and web frameworks tend to go together) does not work in Go http://www.hydrogen18.com/blog/golang-orms-and-why-im-still-..., lots of interesting points in it. Especially regarding how some people start out thinking in terms of objects, while others think in terms of database schema. Go is geared towards the latter kind, people who prefer to think at the low level, and the idea of a very high level tool that provides you web abstractions and ORM is foreign to that. In this respect it's not all that different from the C world, where there aren't any web/orm frameworks either and nobody misses them.
Re:Show HN: Getting started with Go and Martini by bpicolo on Monday April 27, 2015 @11:43AM (#9446997)
I've tried out a number of new-fangled languages from a web development perspective (Rust, Go with gorilla, primarily) and in my opinion don't really provide the same set of tools for this sort of web development as higher-level languages like python, ruby, js w/node. That's not to say they don't have important use cases, they just aren't designed with this sort of web development in mind.

And of course, it's totally valid to prefer the different paradigm that these provide! Hasn't been ideal for me, though.

Services though? Totally an appropriate time to fire up Go, in my opinion.

And, even then, Python (which I'm most familiar with) has downsides for JSON services. Translating from an ORM (sqlalchemy) to formatted JSON is something you have to relegate to some magical methods or do one by one, neither is a great solution.

Re:Show HN: Getting started with Go and Martini by gtrubetskoy on Monday April 27, 2015 @01:59PM (#9447996)
Yes, services is where Go has a huge advantage over Python and Ruby in particular because of their inability to leverage SMP due to the GIL. With Go you don't need to run a whole bunch of processes behind haproxy or whatever which makes life much easier.
Re:Show HN: Getting started with Go and Martini by dragonwriter on Monday April 27, 2015 @05:43PM (#9449289)
> Yes, services is where Go has a huge advantage over Python and Ruby in particular because of their inability to leverage SMP due to the GIL.

That would be an advantage of Go-as-a-language over Ruby-as-a-language in a world where JRuby didn't exist.

Re:Show HN: Getting started with Go and Martini by j_mcnally on Monday April 27, 2015 @11:46AM (#9447022)
Perhaps I should revise with more of a focus on JSON/Services. I was trying to stick to a common pattern across languages. But that might not be the best approach.
Re:Show HN: Getting started with Go and Martini by Spiritus on Monday April 27, 2015 @11:16AM (#9446824)
This is another good walkthrough which focus more on what is perhaps considered more "idiomatic Go" than using Martini.

http://nicolasmerouze.com/build-web-framework-golang/

Re:Show HN: Getting started with Go and Martini by apertoire on Monday April 27, 2015 @11:16AM (#9446813)
I would have to say that https://gin-gonic.github.io/gin/ is probably a better framework. I've used it in a proof of concept app (http://jbrodriguez.io/introducing-mediabase/) and it's really fast.
Re:Show HN: Getting started with Go and Martini by j_mcnally on Monday April 27, 2015 @11:37AM (#9446960)
Yeah i found out about that after i wrote this guide, will be doing another / revised guide based on Gin.
Re:Show HN: Getting started with Go and Martini by anacleto on Monday April 27, 2015 @10:56AM (#9446678)
Interesting stuff.
Re:Show HN: Getting started with Go and Martini by amelius on Monday April 27, 2015 @11:00AM (#9446700)
Go already has an HTTP server in its standard library ([1]) so why write another one?

[1] http://golang.org/pkg/net/http/

Re:Show HN: Getting started with Go and Martini by aikah on Monday April 27, 2015 @11:47AM (#9447030)
Does it handle route variables? no

Does it have a middleware stack? no

Martini is a request router not a http server.

Re:Show HN: Getting started with Go and Martini by tyho on Monday April 27, 2015 @12:11PM (#9447181)
You can easily handle route variables yourself with very simple logic.

You can wrap http.HandleFunc to make it behave like middleware.

You do not need to import a framework for these things:

https://vimeo.com/115940590

Re:Show HN: Getting started with Go and Martini by aikah on Monday April 27, 2015 @02:01PM (#9448019)
> You can easily handle route variables yourself with very simple logic.

But you linked a talk that recommends a library to deal with route variables.

> You can wrap http.HandleFunc to make it behave like middleware.

But you linked a talk that recommends a library to deal with middlewares.

Maybe you should review the links you post at first place.

Re:Show HN: Getting started with Go and Martini by aikah on Monday April 27, 2015 @12:22PM (#9447259)
Yes I can write an unmaintainable spaghetti mess, or I can isolate a specific business domain and write or use a library that solves this problem once and for all.

Because at the end of the day it's me who end up testing and running that code, not you.

Re:Show HN: Getting started with Go and Martini by nindalf on Monday April 27, 2015 @02:05PM (#9448047)
I think you ought to reconsider what the other guy said. His suggestions were quite good because they lead to simple, idiomatic code that relies solely on the standard library.

You can read more here - https://medium.com/@matryer/the-http-handlerfunc-wrapper-tec...

Re:Show HN: Getting started with Go and Martini by aikah on Monday April 27, 2015 @03:22PM (#9448553)
I read matt ryer's excellent book "Go Blueprints" already. I know all that stuff. I use middlewares with complex logic, I write apps with hundreds of controllers, so with all due respect I'm not going to reinvent the wheel , each time I need to finish a project with tight deadlines.

I don't understand this Go community mindset which says that "nothing is needed but the std lib". My use case isn't Google's or anybody else's.

If the Go team wanted an idiomatic router or middleware stack well they should have provided fully featured ones in the standard lib. There are none. It means "user land".

Re:Show HN: Getting started with Go and Martini by belak on Monday April 27, 2015 @01:00PM (#9447568)
Have you seen Negroni? It provides a simple framework which solves some the middleware problem. It doesn't use dep injection, the code is more idiomatic and you can use it with any HTTP mux/router you want.
Re:Show HN: Getting started with Go and Martini by shirro on Tuesday April 28, 2015 @04:02AM (#9450960)
Martini is cool but you probably don't need it.

The main thing lacking from net/http is a flexible router. Using the standard mux and parse params out of the request is doable but something like httprouter is often worthwhile.

Wrapping Handle or HandleFunc is easy enough that you don't really need some framework for middleware. If you keep to the standard interface there is plenty of middleware about if you need it. Though you can use things like Gorilla context for request context it is so easy to use a map of requests pointers to data protected by a mutex it seems silly to use a library to do it.

I feel like Go is a bit of an anti-framework language in general. Anyone trying to offer an all-things-to-everyone solution is going to stray into reflection and interface{} everywhere and I think the more Go you write, the less happy you get with this sort of approach.

Re:Show HN: Getting started with Go and Martini by j_mcnally on Monday April 27, 2015 @11:04AM (#9446729)
Simplified DSL / Routing