

A quick and easy way to setup a RESTful JSON API in Go - ant0ine
https://github.com/ant0ine/go-json-rest

======
lazyjones
The "Countries" example does not look correct to me. Go maps aren't safe for
concurrent use (such as parallel REST API requests in this case) and need to
be protected with a sync.RWMutex or similar, although it might work safely in
some special cases (I'm not sure).

~~~
rakoo
I'm pretty sure the map here is not the important part. The example
demonstrates how to use the rest interface to talk with a store. The actual
implementation of the store is up to you.

~~~
skj
I think it's important for example code to also be correct. If it needs to
gloss over some details, put them in a function call that isn't defined.

Using an unprotected map here is incorrect.

~~~
lazyjones
Absolutely! Example code affects programming style and teaches people. It
should be correct (and in good style), this is probably very much underrated.

------
randallsquared
How does this differ from Tiger Tonic ( [https://github.com/rcrowley/go-
tigertonic](https://github.com/rcrowley/go-tigertonic) )?

------
tete
I once read the you aren't supposed to use ORMs in Go. I am not sure why. Does
anyone have an idea?

~~~
NateDad
Many gophers hate magic. ORMs are specifically magic, and therefore not very
popular with many gophers.

Many gophers have a lot of experience in other languages with ORMs and have
been burned by them on many occasions.

I like to say - ORMs make the easy stuff easier, and the hard stuff harder. If
you're only doing really simple object storage and your data model easily fits
with the model the ORM expects, then it's not too bad. If you EVER want to
deviate from that model (and you'll ALWAYS end up wanting to deviate from that
model), then you are gonna have a bad time.

There actually are plenty of Go ORMs: [https://code.google.com/p/go-
wiki/wiki/Projects#ORM](https://code.google.com/p/go-wiki/wiki/Projects#ORM)
(there's probably many that aren't on this list)

Many gophers prefer their code to be more obvious and more under their
control. Writing a little SQL never hurt anyone, and Go's SQL package is
pretty good. Personally, I like
[http://github.com/jmoiron/sqlx](http://github.com/jmoiron/sqlx) \- you have
to write SQL statements still (I consider that a good thing), but it removes
the boilerplate of getting data in and out of structs.

~~~
tptacek
I'm not sure I see the "magic" in trivial compilers.

------
wkdown
Why would I use Go instead of Ruby/Python/nodeJS?

~~~
skj
So you can have a maintainable codebase.

~~~
threeseed
Well that's just nonsense.

You can have maintainable and unmaintainable codebases in any language.

~~~
mistermumble
Clearly you have never run across the same program, first in Perl, and then in
Python, and felt the tangible differences in maintainability between the two
implementations.

