Ask HN: What Go framework for web API are you using in production? - srameshc
======
taneltanel
Using no frameworks at all, only
[https://github.com/julienschmidt/httprouter](https://github.com/julienschmidt/httprouter)
for routing.

~~~
bauerd
How do you handle database schema migrations?

~~~
tptacek
I use Rails migrations, via the standalone_migrations gem, and code-generate
the basic CRUD Go stuff from the schema.

I've tried a bunch of other migration tools but I don't think anyone has done
a better job of it than Rails has.

~~~
bauerd
Cool, because this is actually what I ended up with myself in a dummy Go setup
of mine (after having reinvented AR's migrations poorly with a Bash script).
I'm not really accustomed to Go's ecosystem yet, so:

>and code-generate the basic CRUD Go stuff from the schema

I guess you read schema.rb and output some structs and methods? Because a
quick Google search only yielded some Yeoman plugins …

~~~
tptacek
No, I use Postgres and just query information_schema, and use the row/column
information to populate text/template Go templates.

There's a bunch of tools that do this already (one I know works is "xo"), but
I wanted join-table support.

------
barrongineer
We've been pretty happy with [https://gobuffalo.io](https://gobuffalo.io) so
far. We're serving up a Vue.js app with it. We needed a single binary to
deploy on a client's server with no external dependencies and buffalo fits the
bill. It comes with a cli that runs webpack and does hot reloads on save. It
also has a build command that will bundle all the assets up to shove in the
binary.

------
programd
The Go standard library has most of what you need for basic API servers.
However as has been stated here, some things are not worth spending time
crafting yourself.

Also for modern Docker/Kubernetes ops environments you need some additional
infrastructure for table stakes. Here's my standard Nulladmin.com stack:

Routing - [https://github.com/go-chi/chi](https://github.com/go-chi/chi)

Command flags -
[https://github.com/spf13/pflag](https://github.com/spf13/pflag)

Config - [https://github.com/spf13/viper](https://github.com/spf13/viper)

Logging -
[https://github.com/Sirupsen/logrus](https://github.com/Sirupsen/logrus)

Metrics -
[https://github.com/prometheus/client_golang/prometheus](https://github.com/prometheus/client_golang/prometheus)

SQL helper -
[https://github.com/jmoiron/sqlx](https://github.com/jmoiron/sqlx)

OpenTracing - [https://github.com/opentracing/opentracing-
go](https://github.com/opentracing/opentracing-go)

------
erazor42
[https://echo.labstack.com/](https://echo.labstack.com/)

------
saiongole
[https://github.com/gorilla/mux](https://github.com/gorilla/mux)

~~~
psynapse
Same here.

I love this about Go. A router and you are off and running.

It is so simple to wrap handlers with your own middleware for auth, pre-
flighting etc.

------
nonane
[https://github.com/labstack/echo](https://github.com/labstack/echo)

For building a REST API

------
jstewartmobile
[https://github.com/gin-gonic/gin](https://github.com/gin-gonic/gin)

~~~
NateDad
We use gin. It's mostly fine. If I were starting a new application, I'd
probably use stdlib by itself.

------
richardknop
Just standard library (net/http), no framework. Specific packages for specific
tasks if needed (sqlx for database etc).

------
wvh
I've been using the standard library, httptreemux and Chi, depending on how
large the project is. I have also used Gorilla in the past, and sometimes use
Alice to compose handlers. I prefer to stay close to the standard library, so
as to not get stuck with code that depends too heavily on a third library with
no easy way to entangle that dependency. I've still got nightmares from late
'90s PHP and early 2000 Zope framework disasters... not with a 10 foot pole.
Though when your application gets bigger, it makes sense to pull in a good
library for some route grouping and helper functions – there are so many
options, it's not worth your while to roll your own.

And unless you have very specific requirements, the performance is probably
not a relevant concern in a real application either.

------
cristaloleg
[https://github.com/go-chi/chi](https://github.com/go-chi/chi)

------
prettynatty
grpc-go ([https://github.com/grpc/grpc-go](https://github.com/grpc/grpc-go)) +
grpc-gateway ([https://github.com/grpc-ecosystem/grpc-
gateway](https://github.com/grpc-ecosystem/grpc-gateway))

~~~
krullie
Same here. I was sceptical about code generation and the whole protobuf as a
base thing but i'm really liking it. Especially when you throw opentracing in
the mix.

------
philip1209
We run grpc-web with a big single-page VueJS app on the frontend. That way, Go
is just the Api server, and the frontend handles all the routing and stuff.

~~~
Dlotan
We will also try to go this path. What is your overall satisfaction with this
approach? I saw that grpc-web is marked as alpha and the grpc team itself
wants to implement something which is kind of comparable.

~~~
philip1209
It's been good. I need to figure out SSR, either in Go or though a Node
microservice.

I really like how a proto file defines our whole Api. It makes designing and
referencing the Api easy.

------
gnahckire
Currently using gokit: [https://github.com/go-kit/kit](https://github.com/go-
kit/kit)

Really nice interface for adding tracing, middleware/finalizer
logging/metrics, circuit-breakers, etc to your application.

~~~
prettynatty
But sadly no streaming yet

------
tmaly
I am using Gin for my food side project
[https://bestfoodnearme.com](https://bestfoodnearme.com)

at my day job in fintech I use the standard library and gorilla/mux

------
petepete
I'm using Negroni middleware and Vestigo for routing. Both are _simple_ , fast
and elegant, and are being actively developed.

[0] [https://github.com/urfave/negroni](https://github.com/urfave/negroni)

[1] [https://github.com/husobee/vestigo](https://github.com/husobee/vestigo)

------
dash1291
At Grofers, we built a framework using Swagger that we use for building
aggregated APIs and also open-sourced it couple of days back. It can be found
here - [https://github.com/grofers/go-codon](https://github.com/grofers/go-
codon)

------
samblr
Can anybody share experience with gobuffalo.

[https://gobuffalo.io/](https://gobuffalo.io/)

------
nilslice
[https://ponzu-cms.org](https://ponzu-cms.org) for back end &
[https://github.com/gorilla/mux](https://github.com/gorilla/mux) if needs a Go
front end.

------
nicpottier
Chi gives us just enough while still adhering to all the Golang standards:
[https://github.com/go-chi/chi](https://github.com/go-chi/chi)

Do augment it a bit here and there with other libraries.

------
Queue29
net/http with gorilla/mux for routing

~~~
richardknop
Same here. I never really liked idea of frameworks like Spring/Django for
Golang. Rather build very small services and mostly use just standard library,
perhaps some simple packages for specific tasks.

------
chimen
I use beego.me for [https://typely.com](https://typely.com) and It's great so
far. It has a lot of features but I use just a few which worked great from day
1.

------
codehack
I wrote my own lightweight framework - [https://github.com/codehack/go-
relax](https://github.com/codehack/go-relax)

------
zacharynewton
Gin for most parts Zap for logging Then Docker up the binary in busybox and
run on AWS ECS

I've tinkered with echo and a couple other frameworks, but Gin is widely used
enough that I can usually stack overflow most issues.

------
ollieco
Not a full blown framework, but Chi works pretty well -
[https://github.com/go-chi/chi](https://github.com/go-chi/chi)

~~~
GeertJohan
I am using Chi in several projects running in large production environments.

------
hiepph
Just a router is enough for me
[https://github.com/buaazp/fasthttprouter](https://github.com/buaazp/fasthttprouter)

------
crehn
[https://github.com/valyala/fasthttp](https://github.com/valyala/fasthttp)

Crazy fast and has worked fine under heavy load.

------
dblooman
[https://github.com/ant0ine/go-json-rest](https://github.com/ant0ine/go-json-
rest)

~~~
garfij
We use this too. It's not bad if all you're ever doing is returning json, but
escaping from their `rest.ResponseWriter` to a normal `http.ResponseWriter` is
always sad when you need to write out anything else.

That's a pretty good summary of the rest of it for me too...pretty good, but
sad that it doesn't adhere to the standard libs `http` interfaces

------
misframer
[https://github.com/VividCortex/siesta](https://github.com/VividCortex/siesta)

------
agnivade
No framework as such. Just some tools from here and there - gorilla/mux +
negroni + net/http.

------
telefonica
[https://github.com/goadesign/goa](https://github.com/goadesign/goa)

------
subsidd
What has been your experience with gin? How do you use it in your application?

------
willygold
httprouter is all I need

------
ddw
net/http and Gorilla Mux

