News for hackers. Stuff that matters.
Re:Ask HN: What is your Golang web-dev tech stack? by mdasen on Tuesday December 05, 2017 @01:24PM (#15854155)
I've started using Echo[1] and it seems to provide most of what I'm looking for (routing, context, sessions, CSRF protection, form/json binding, etc). For templating, I'm using QuickTemplate[2] which creates statically generated templates, but Pongo2[3] and Jet[4] also look reasonable. sqlx[5], gorm[6], and sqlboiler[7] all seem reasonable for database access, depending on what your style is (sqlx being oriented toward manual statements, gorm being reflection-based orm-ish, and sqlboiler using go generate's code generation to make statically generated access for you).

If you don't want to piece things together yourself (and want a more Rails-like experience), Buffalo[8] is probably your best bet.

[1] https://echo.labstack.com/

[2] https://github.com/valyala/quicktemplate

[3] https://github.com/flosch/pongo2

[4] https://github.com/CloudyKit/jet

[5] https://github.com/jmoiron/sqlx

[6] https://github.com/jinzhu/gorm

[7] https://github.com/volatiletech/sqlboiler

[8] https://github.com/gobuffalo/buffalo

Re:Ask HN: What is your Golang web-dev tech stack? by alain_gilbert on Wednesday December 06, 2017 @04:40AM (#15859811)
I started using "realize" to get live realod [9].

And I also use "bindata" to compile all my static files into the final binary [10].

[9] https://github.com/tockins/realize

[10] https://github.com/jteeuwen/go-bindata

Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Tuesday December 05, 2017 @01:29PM (#15854229)
Sweet! Buffalo looks really interesting. I was playing with Sails the other day, which is a Rails-like framework for nodejs, I will try Buffalo and try to compare the experience. Would you recommend Buffalo for a JSON Web API mobile backend project or would it be an overkill?
Re:Ask HN: What is your Golang web-dev tech stack? by OhSoHumble on Tuesday December 05, 2017 @03:14PM (#15855353)
I don't know how relevant it is, but the creator of Buffalo has a video explaining how to hook up Vue to the framework: https://blog.gobuffalo.io/using-vue-js-with-buffalo-video-ee...
Re:Ask HN: What is your Golang web-dev tech stack? by barrongineer on Tuesday December 05, 2017 @01:47PM (#15854454)
It's fine for an api as well. When you create your app, just use the --api flag and it will leave out all of the front-end stuff.
Re:Ask HN: What is your Golang web-dev tech stack? by tptacek on Tuesday December 05, 2017 @01:31PM (#15854248)
Is there a way to use Echo where you're not using their weird handler interface, but rather just standard net/http Handlers?
Re:Ask HN: What is your Golang web-dev tech stack? by tptacek on Tuesday December 05, 2017 @01:29PM (#15854233)
Even though I know they're well-designed, I find Go's web templates hard to work in. So I avoid them.

My stack is basically:

- Postgres, using pq and sqlx

- A codegen ORM I wrote that scrapes schemas and generates CRUD and lookup functions for all my database types. I don't think dynamic ORMs like gorm are the way to go for Go.

- A session library I wrote a year ago, and simple Go wrapper handlers to require sessions, enforce authentication, &c, passing things like "current user" and "current session" down to standard net/http Handlers through Context.

- 10-or-so JSON utility functions I take with me from project to project.

- React, via create-react-app, so I all my templating is done in JSX.

- net/http/httptest for testing.

Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Tuesday December 05, 2017 @06:22PM (#15857112)
Any chance you have that ORM of yours open-sourced somewhere?
Re:Ask HN: What is your Golang web-dev tech stack? by tptacek on Tuesday December 05, 2017 @06:44PM (#15857274)
No, but (1) sqlboiler is a much better ORM, and (2) it is surprisingly easy to build these things yourself; mine's just a bunch of text/template templates and ~100 lines of Go code to scrape a Postgres schema.

(I mean: this code will be open sourced pretty soon, since it's part of a bigger open source thingy I'm releasing, but the ORM isn't very good, just as good as I needed it to be; nobody should ever use it for another project.)

Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Wednesday December 06, 2017 @02:57AM (#15859365)
Go it. Sounds like a fun educational project to build, an ORM tgat scrapes a PostgreSQL database and provides primitives to query it.
Re:Ask HN: What is your Golang web-dev tech stack? by avitzurel on Tuesday December 05, 2017 @12:39PM (#15853587)
My 2 cents

At Globality[1], we use microcosm [2], an internally built framework for crafting applications. We have 45+ microservices, all built on top of it, and it's a joy.

I was looking for a framework that will give me similar benefits with Golang. Something that I can take out of the box with some convention-over-configuration.

I found micro [3] and gizmo [4]. (There are more)

It seems to me that a full-blown web app doesn't come very natural to Golang yet. There isn't a framework that will give you what you are used for from other languages/frameworks.

I have a lot of experience with Golang and built many tools, and it always felt more natural to me when there is no database/models involved.

[1] https://www.globality.com/en-us/

[2] https://github.com/globality-corp/?utf8=%E2%9C%93&q=microcos...

[3] https://github.com/micro/go-micro

[4] https://github.com/NYTimes/gizmo

Re:Ask HN: What is your Golang web-dev tech stack? by nerdywordy on Tuesday December 05, 2017 @01:34PM (#15854300)
Gophers tend to roll their own and forego larger frameworks.

Piecing together libraries can absolutely be daunting, but once you get a starter app built your productivity will go way, way up.

I'd really recommend this (paid) course at https://www.usegolang.com

It walks you through pulling in different libraries (Gorilla Mux, GORM, etc), gluing them together, and structuring your code in a maintainable way.

A couple of other folks have mentioned Buffalo. It's a great ecosystem for building applications quickly, but I would strongly urge you to go through gluing the packages together yourself first to really understand what is going on underneath the magic.

Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Tuesday December 05, 2017 @06:25PM (#15857130)
Solid advice. I will take a look at the course, looks interesting. Thanks for sharing.
Re:Ask HN: What is your Golang web-dev tech stack? by matthiase on Tuesday December 05, 2017 @12:44PM (#15853654)
For APIs, I've used net/http and httprouter with great success. I've recently discovered Buffalo (https://github.com/gobuffalo/buffalo) which looks great for full-stack development but I have not used it for a production app.
Re:Ask HN: What is your Golang web-dev tech stack? by indescions_2017 on Tuesday December 05, 2017 @02:04PM (#15854644)
Also check out Træfik. A fast reverse proxy. With support for kubernetes, prometheus, let's encrypt, grpc, websockets and more. It may change the way you design your web backend ;)

https://traefik.io/

Am also looking forward to trying the new GoLand IDE from the JetBrains team. Currently using Atom but would be interested in dedicated integrations with gcloud sdk.

https://www.jetbrains.com/go/

Re:Ask HN: What is your Golang web-dev tech stack? by marcrosoft on Tuesday December 05, 2017 @01:13PM (#15854040)
Go with sqlite DB using net/http, httprouter, and gorm. The goal is maintainability and easy deployment over scalability.
Re:Ask HN: What is your Golang web-dev tech stack? by gtrubetskoy on Tuesday December 05, 2017 @02:05PM (#15854657)
Plain Go, no frameworks (may be a little Gorilla toolkit components such as their mux), Postgres with sqlx and React on the front end. I describe it in detail here:

https://grisha.org/blog/2017/04/27/simplistic-go-web-app/

Re:Ask HN: What is your Golang web-dev tech stack? by bigdubs on Tuesday December 05, 2017 @02:22PM (#15854844)
We rolled our own, nice benefit is everything registers events with the same logging subsystem and lets us define central hooks for common things like errors (to send to reporters).

Web: https://github.com/blendlabs/go-web

DB: https://github.com/blendlabs/spiffy

Migrations: https://github.com/blendlabs/spiffy/migration

Logger: https://github.com/blendlabs/go-logger

CRON: https://github.com/blendlabs/go-chronometer

Re:Ask HN: What is your Golang web-dev tech stack? by didip on Tuesday December 05, 2017 @02:14PM (#15854758)
* Standard library for a lot of things.

* https://github.com/go-chi/chi is pretty good. I have a need for a lot of custom middlewares, so I need something more fleshed out than net/http.

* All config files are written in TOML: https://github.com/BurntSushi/toml

* https://github.com/gocql/gocql for all Cassandra needs.

* Development work is done in Docker so everyone has a consistent env.

That's all, I tend to dislike overarching frameworks. Smaller libraries work better for me.

Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Tuesday December 05, 2017 @06:20PM (#15857085)
Just took a look at Chi's RESTful API example, I like it. I also like the benchmarks. Judging by most of the comments on this thread, it looks like the community favors modular small tools over big fat frameworks, is that true?
Re:Ask HN: What is your Golang web-dev tech stack? by didip on Tuesday December 05, 2017 @08:38PM (#15857818)
I’d say so.

Big framework comes at big cost when trying to upgrade to a new version because it’s surface area is big.

Re:Ask HN: What is your Golang web-dev tech stack? by t3h2mas on Tuesday December 05, 2017 @03:14PM (#15855354)
Gin/React. I was using templates but decided to offload some display logic on the frontend instead of creating more API endpoints. So I switched to React. I dig writing decoupled front/backends
Re:Ask HN: What is your Golang web-dev tech stack? by cmrajan on Tuesday December 05, 2017 @05:59PM (#15856911)
I've been using a starter kit[1] to build our API.For database access using Modl[2] similar to gorp but uses sqlx internally. Much of the data access code is generated as I'm of opinion reflection based ORM doesn't lend itself well in Go.

[1]https://github.com/qiangxue/golang-restful-starter-kit

[2]https://github.com/jmoiron/modl

Re:Ask HN: What is your Golang web-dev tech stack? by acangiano on Tuesday December 05, 2017 @01:24PM (#15854153)
If you are creating an SPA application and you just need an API in Go, the standard library or one of the microframeworks like Gin work fine. If you are doing full-stack development, you'll be more productive with a framework even though the Go community tends to shy away from large frameworks. If I were to use Go for a web app today, I'd use Buffalo which is relatively Rails-like while still being very modular: https://gobuffalo.io/
Re:Ask HN: What is your Golang web-dev tech stack? by Bjorkbat on Tuesday December 05, 2017 @12:47PM (#15853707)
I use it as a RESTful API for a single page app. I use some extra packages beyond those that come standard, but they don't really have a huge day-to-day impact on the code that I write.

Gorilla will probably make your life easier. I rely on the mux package quite a bit for routing purposes.

I also use Google's jsonapi package to maintain a semblance of orderliness when it comes to request and response data, but I wouldn't be hurting too much without it.

Re:Ask HN: What is your Golang web-dev tech stack? by cyrusaf on Tuesday December 05, 2017 @02:00PM (#15854608)
HTTP: - gRPC for microservices - graphql for combining microservices for the frontend

DB: - dynamodb/psql depending on features. aws-sdk or base go sql package. - redis for caching. go-redis package.

Stats/logging: - statsd/graphite/grafana - sirupsen/logrus for logging

I usually write a wrapper for packages that will automatically report stats + logging.

Re:Ask HN: What is your Golang web-dev tech stack? by BlackjackCF on Tuesday December 05, 2017 @01:54PM (#15854531)
I've used Echo in the past along with sqlx and Gorm.

I've found myself enjoying rolling/being more explicit about what it is that I need, so I now build out small web APIs just using a combination of Gorilla Mux + net/http.

Re:Ask HN: What is your Golang web-dev tech stack? by bjw181 on Tuesday December 05, 2017 @07:29PM (#15857509)
I'm curious. I've used GoLang's simple web server before, but I'm interested in what GoLang provides over Node. To me, it seems Go is especially well suited for microservices and tasks requiring a lot of CPU intensive processes while Node is better when working with small requests over the wire.

In other words, what is Go's main selling point in competing with Node in terms of its http server, TCP sockets, etc...

Can Go's awesome concurrency patterns be used to optimize server requests? Can it be well utilized as a proxy?

Re:Ask HN: What is your Golang web-dev tech stack? by weitzj on Tuesday December 05, 2017 @02:39PM (#15855041)
gRPC, gRPC-Gateway, pgx, memcached, gorilla secure cookie, gorilla CSRF, gRPC-opentracing with Google Stackdriver integration, Uber-zap logging
Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Tuesday December 05, 2017 @06:06PM (#15856969)
Interesting. What do you use gRPC for?
Re:Ask HN: What is your Golang web-dev tech stack? by weitzj on Wednesday December 06, 2017 @02:57AM (#15859363)
To document and generate the api client and server stubs. Server is implemented in Go, clients are either Android, iOS or a Browser.

Android uses grpc-java iOS uses grpc-objc Browser uses gRPC-Gateway and the JSON equivalent of the protobuf3 spec.

Re:Ask HN: What is your Golang web-dev tech stack? by atis on Tuesday December 05, 2017 @01:55PM (#15854553)
Re:Ask HN: What is your Golang web-dev tech stack? by barrongineer on Tuesday December 05, 2017 @01:46PM (#15854428)
Re:Ask HN: What is your Golang web-dev tech stack? by dahx4Eev on Tuesday December 05, 2017 @07:09PM (#15857416)
routing/binding/cors: chi / echo

database: sqlx, upper, sqlboiler

log: zap, zerolog

dependency management: dep

config: viper

cli: cobra

lint: gometalinter

Trying https://github.com/improbable-eng/grpc-web and http://rest-layer.io

Re:Ask HN: What is your Golang web-dev tech stack? by nimajalali on Tuesday December 05, 2017 @05:27PM (#15856639)
Re:Ask HN: What is your Golang web-dev tech stack? by tmaly on Tuesday December 05, 2017 @02:58PM (#15855228)
I have used gin / libpq / sqlx for my food side project.

At my day job I use the standard library.

Re:Ask HN: What is your Golang web-dev tech stack? by ShabbosGoy on Tuesday December 05, 2017 @01:14PM (#15854052)
We use Gin-Gonic with sqlx for our REST API. We also use Gorilla for Websockets.
Re:Ask HN: What is your Golang web-dev tech stack? by OhSoHumble on Tuesday December 05, 2017 @03:16PM (#15855372)
I use Buffalo for an API and Vue.js with TypeScript as a frontend.
Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Tuesday December 05, 2017 @06:09PM (#15856994)
Cool. How do you serve your frontend app? Do you do it via Buffalo or nodejs?
Re:Ask HN: What is your Golang web-dev tech stack? by OhSoHumble on Tuesday December 05, 2017 @06:28PM (#15857155)
Currently? I run them on separate ports and use axios[0] to make requests against Buffalo routes. I had to use the github.com/rs/cors[1] package with Buffalo for CORS so that Vue doesn't yell at me. So I run `buffalo dev` in one tmux pane and `yarn dev` in another.

Here is what the inside of the <script> portion of a component may look like: https://gist.github.com/howdoicomputer/cdadba6e47021ba90b7f7...

And here is the code for adding cors to Buffalo: https://gist.github.com/howdoicomputer/17366df6cd7b8208a22a8... I got that from a PR for pre-app handlers. [2]

Eventually, I'll hook everything up to Nginx for deployment.

[0] https://github.com/axios/axios [1] https://github.com/rs/cors [2] https://github.com/gobuffalo/buffalo/issues/609

Re:Ask HN: What is your Golang web-dev tech stack? by rickbad68 on Tuesday December 05, 2017 @04:10PM (#15856017)
spf13/cobra spf13/viper joho/godotenv mattes/migrate postgres go-pg/pg gorilla/mux gorilla/sessions net/http html/template
Re:Ask HN: What is your Golang web-dev tech stack? by brightball on Tuesday December 05, 2017 @12:35PM (#15853504)
IMO this space is a pain point for Go compared to other languages. If you have a single page app talking to APIs it’s less of an issue though.
Re:Ask HN: What is your Golang web-dev tech stack? by aalhour on Tuesday December 05, 2017 @06:08PM (#15856979)
What about JSON API that is hooked up with a relational database, say PostgreSQL, no frontend?
Re:Ask HN: What is your Golang web-dev tech stack? by maerF0x0 on Tuesday December 05, 2017 @12:36PM (#15853546)
net/http
Re:Ask HN: What is your Golang web-dev tech stack? by davidsonff on Tuesday December 05, 2017 @03:52PM (#15855828)
Go, Polymer, Redux.
Re:Ask HN: What is your Golang web-dev tech stack? by mmargerum on Thursday December 07, 2017 @08:37AM (#15869833)
Gorilla + Vue.js