TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What is your Golang web-dev tech stack?

98 点作者 aalhour超过 7 年前
I picked up Golang recently and I am curious about how people use it to develop web applications. How does your tech stack look like?

30 条评论

mdasen超过 7 年前
I&#x27;ve started using Echo[1] and it seems to provide most of what I&#x27;m looking for (routing, context, sessions, CSRF protection, form&#x2F;json binding, etc). For templating, I&#x27;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&#x27;s code generation to make statically generated access for you).<p>If you don&#x27;t want to piece things together yourself (and want a more Rails-like experience), Buffalo[8] is probably your best bet.<p>[1] <a href="https:&#x2F;&#x2F;echo.labstack.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;echo.labstack.com&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;valyala&#x2F;quicktemplate" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;valyala&#x2F;quicktemplate</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;flosch&#x2F;pongo2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;flosch&#x2F;pongo2</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;CloudyKit&#x2F;jet" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;CloudyKit&#x2F;jet</a><p>[5] <a href="https:&#x2F;&#x2F;github.com&#x2F;jmoiron&#x2F;sqlx" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jmoiron&#x2F;sqlx</a><p>[6] <a href="https:&#x2F;&#x2F;github.com&#x2F;jinzhu&#x2F;gorm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jinzhu&#x2F;gorm</a><p>[7] <a href="https:&#x2F;&#x2F;github.com&#x2F;volatiletech&#x2F;sqlboiler" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;volatiletech&#x2F;sqlboiler</a><p>[8] <a href="https:&#x2F;&#x2F;github.com&#x2F;gobuffalo&#x2F;buffalo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gobuffalo&#x2F;buffalo</a>
评论 #15859811 未加载
评论 #15854229 未加载
评论 #15854248 未加载
tptacek超过 7 年前
Even though I know they&#x27;re well-designed, I find Go&#x27;s web templates hard to work in. So I avoid them.<p>My stack is basically:<p>- Postgres, using pq and sqlx<p>- A codegen ORM I wrote that scrapes schemas and generates CRUD and lookup functions for all my database types. I don&#x27;t think dynamic ORMs like gorm are the way to go for Go.<p>- A session library I wrote a year ago, and simple Go wrapper handlers to require sessions, enforce authentication, &amp;c, passing things like &quot;current user&quot; and &quot;current session&quot; down to standard net&#x2F;http Handlers through Context.<p>- 10-or-so JSON utility functions I take with me from project to project.<p>- React, via create-react-app, so I all my templating is done in JSX.<p>- net&#x2F;http&#x2F;httptest for testing.
评论 #15857112 未加载
avitzurel超过 7 年前
My 2 cents<p>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&#x27;s a joy.<p>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.<p>I found micro [3] and gizmo [4]. (There are more)<p>It seems to me that a full-blown web app doesn&#x27;t come very natural to Golang yet. There isn&#x27;t a framework that will give you what you are used for from other languages&#x2F;frameworks.<p>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&#x2F;models involved.<p>[1] <a href="https:&#x2F;&#x2F;www.globality.com&#x2F;en-us&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.globality.com&#x2F;en-us&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;globality-corp&#x2F;?utf8=%E2%9C%93&amp;q=microcosm&amp;type=&amp;language=" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;globality-corp&#x2F;?utf8=%E2%9C%93&amp;q=microcos...</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;micro&#x2F;go-micro" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;micro&#x2F;go-micro</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;NYTimes&#x2F;gizmo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;NYTimes&#x2F;gizmo</a>
nerdywordy超过 7 年前
Gophers tend to roll their own and forego larger frameworks.<p>Piecing together libraries can absolutely be daunting, but once you get a starter app built your productivity will go way, way up.<p>I&#x27;d really recommend this (paid) course at <a href="https:&#x2F;&#x2F;www.usegolang.com" rel="nofollow">https:&#x2F;&#x2F;www.usegolang.com</a><p>It walks you through pulling in different libraries (Gorilla Mux, GORM, etc), gluing them together, and structuring your code in a maintainable way.<p>A couple of other folks have mentioned Buffalo. It&#x27;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.
评论 #15857130 未加载
matthiase超过 7 年前
For APIs, I&#x27;ve used net&#x2F;http and httprouter with great success. I&#x27;ve recently discovered Buffalo (<a href="https:&#x2F;&#x2F;github.com&#x2F;gobuffalo&#x2F;buffalo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gobuffalo&#x2F;buffalo</a>) which looks great for full-stack development but I have not used it for a production app.
indescions_2017超过 7 年前
Also check out Træfik. A fast reverse proxy. With support for kubernetes, prometheus, let&#x27;s encrypt, grpc, websockets and more. It may change the way you design your web backend ;)<p><a href="https:&#x2F;&#x2F;traefik.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;traefik.io&#x2F;</a><p>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.<p><a href="https:&#x2F;&#x2F;www.jetbrains.com&#x2F;go&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.jetbrains.com&#x2F;go&#x2F;</a>
marcrosoft超过 7 年前
Go with sqlite DB using net&#x2F;http, httprouter, and gorm. The goal is maintainability and easy deployment over scalability.
gtrubetskoy超过 7 年前
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:<p><a href="https:&#x2F;&#x2F;grisha.org&#x2F;blog&#x2F;2017&#x2F;04&#x2F;27&#x2F;simplistic-go-web-app&#x2F;" rel="nofollow">https:&#x2F;&#x2F;grisha.org&#x2F;blog&#x2F;2017&#x2F;04&#x2F;27&#x2F;simplistic-go-web-app&#x2F;</a>
bigdubs超过 7 年前
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).<p>Web: <a href="https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;go-web" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;go-web</a><p>DB: <a href="https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;spiffy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;spiffy</a><p>Migrations: <a href="https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;spiffy&#x2F;migration" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;spiffy&#x2F;migration</a><p>Logger: <a href="https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;go-logger" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;go-logger</a><p>CRON: <a href="https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;go-chronometer" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blendlabs&#x2F;go-chronometer</a>
didip超过 7 年前
* Standard library for a lot of things.<p>* <a href="https:&#x2F;&#x2F;github.com&#x2F;go-chi&#x2F;chi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;go-chi&#x2F;chi</a> is pretty good. I have a need for a lot of custom middlewares, so I need something more fleshed out than net&#x2F;http.<p>* All config files are written in TOML: <a href="https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;toml" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;toml</a><p>* <a href="https:&#x2F;&#x2F;github.com&#x2F;gocql&#x2F;gocql" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gocql&#x2F;gocql</a> for all Cassandra needs.<p>* Development work is done in Docker so everyone has a consistent env.<p>That&#x27;s all, I tend to dislike overarching frameworks. Smaller libraries work better for me.
评论 #15857085 未加载
t3h2mas超过 7 年前
Gin&#x2F;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&#x2F;backends
cmrajan超过 7 年前
I&#x27;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&#x27;m of opinion reflection based ORM doesn&#x27;t lend itself well in Go.<p>[1]<a href="https:&#x2F;&#x2F;github.com&#x2F;qiangxue&#x2F;golang-restful-starter-kit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;qiangxue&#x2F;golang-restful-starter-kit</a><p>[2]<a href="https:&#x2F;&#x2F;github.com&#x2F;jmoiron&#x2F;modl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jmoiron&#x2F;modl</a>
acangiano超过 7 年前
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&#x27;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&#x27;d use Buffalo which is relatively Rails-like while still being very modular: <a href="https:&#x2F;&#x2F;gobuffalo.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gobuffalo.io&#x2F;</a>
Bjorkbat超过 7 年前
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&#x27;t really have a huge day-to-day impact on the code that I write.<p>Gorilla will probably make your life easier. I rely on the mux package quite a bit for routing purposes.<p>I also use Google&#x27;s jsonapi package to maintain a semblance of orderliness when it comes to request and response data, but I wouldn&#x27;t be hurting too much without it.
cyrusaf超过 7 年前
HTTP: - gRPC for microservices - graphql for combining microservices for the frontend<p>DB: - dynamodb&#x2F;psql depending on features. aws-sdk or base go sql package. - redis for caching. go-redis package.<p>Stats&#x2F;logging: - statsd&#x2F;graphite&#x2F;grafana - sirupsen&#x2F;logrus for logging<p>I usually write a wrapper for packages that will automatically report stats + logging.
BlackjackCF超过 7 年前
I&#x27;ve used Echo in the past along with sqlx and Gorm.<p>I&#x27;ve found myself enjoying rolling&#x2F;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&#x2F;http.
bjw181超过 7 年前
I&#x27;m curious. I&#x27;ve used GoLang&#x27;s simple web server before, but I&#x27;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.<p>In other words, what is Go&#x27;s main selling point in competing with Node in terms of its http server, TCP sockets, etc...<p>Can Go&#x27;s awesome concurrency patterns be used to optimize server requests? Can it be well utilized as a proxy?
weitzj超过 7 年前
gRPC, gRPC-Gateway, pgx, memcached, gorilla secure cookie, gorilla CSRF, gRPC-opentracing with Google Stackdriver integration, Uber-zap logging
评论 #15856969 未加载
atis超过 7 年前
<a href="https:&#x2F;&#x2F;github.com&#x2F;go-chi&#x2F;chi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;go-chi&#x2F;chi</a>
barrongineer超过 7 年前
Buffalo - <a href="https:&#x2F;&#x2F;gobuffalo.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gobuffalo.io&#x2F;</a>
dahx4Eev超过 7 年前
routing&#x2F;binding&#x2F;cors: chi &#x2F; echo<p>database: sqlx, upper, sqlboiler<p>log: zap, zerolog<p>dependency management: dep<p>config: viper<p>cli: cobra<p>lint: gometalinter<p>Trying <a href="https:&#x2F;&#x2F;github.com&#x2F;improbable-eng&#x2F;grpc-web" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;improbable-eng&#x2F;grpc-web</a> and <a href="http:&#x2F;&#x2F;rest-layer.io" rel="nofollow">http:&#x2F;&#x2F;rest-layer.io</a>
nimajalali超过 7 年前
go-kit <a href="https:&#x2F;&#x2F;gokit.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gokit.io&#x2F;</a>
tmaly超过 7 年前
I have used gin &#x2F; libpq &#x2F; sqlx for my food side project.<p>At my day job I use the standard library.
ShabbosGoy超过 7 年前
We use Gin-Gonic with sqlx for our REST API. We also use Gorilla for Websockets.
OhSoHumble超过 7 年前
I use Buffalo for an API and Vue.js with TypeScript as a frontend.
评论 #15856994 未加载
rickbad68超过 7 年前
spf13&#x2F;cobra spf13&#x2F;viper joho&#x2F;godotenv mattes&#x2F;migrate postgres go-pg&#x2F;pg gorilla&#x2F;mux gorilla&#x2F;sessions net&#x2F;http html&#x2F;template
brightball超过 7 年前
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.
评论 #15856979 未加载
maerF0x0超过 7 年前
net&#x2F;http
davidsonff超过 7 年前
Go, Polymer, Redux.
mmargerum超过 7 年前
Gorilla + Vue.js