Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Are you using Go for web development?
65 points by iio7 on March 25, 2021 | hide | past | favorite | 41 comments
If so what is your workflow and what do you use? What do you find most difficult, if anything?


I start small: vim, makefile, bare Go with no dependencies. I add things only if they improve the end product from the consumer perspective (either FRs or NFRs). I even used to deploy things as systemd services, unless containers make things easier to more scalable. For the frontend I couldn't be happier since I discovered "esbuild", which is written in Go and has unbelievable performance.

I tried to describe my humble workflow here with a few code snippets: https://zserge.com/posts/go-web-services/


And 1 year later you've finally deployed a registration form.

And 6 years laters you've invented an undocumented poor man's version of Flask.

And 16 years laters you invented your own ruby on rails, except with no community, no third party libraries, no support and no documentations.

At some point you've left the company and some poor soul is dealing with your simplicity.


> And 1 year later you've finally deployed a registration form.

This made me laugh. What's wrong with tailor-made software? It seems that all we care about nowadays is to "get shit done". I wish this kind of thinking vanishes soon.


Do custom software for personal projects. Not justifying your paycheck. I too have been the sorry sod that was handed a legacy project in a PHP self-rolled framework. I really did contemplate the consequences of my reaction after pouring weeks into the "Easy" solution. My options were to vent my frustration by throwing a brick at someone or drink myself to sleep for two months straight. I chose the latter.

This is not hyperbole.


It's extremely hard to justify the value it provides over something more out of the box. From an engineering perspective, it makes sense. From a business perspective, it often doesn't make sense to spend 10x as much money to make users 10% happier. It almost certainly won't cause you to make 10x as much money.


The above user mentioned what‘s wrong with writing everything from scratch, but you chose to conveniently skip it.

Developers stay only for short amount of times compared to the lifetime of the product. New developers inherit all the tech debt, bugs and bad decisions in your custom framework.


I was only speaking about one-man personal projects. In my case, I shipped 3 of them (nullitics, lalatabs and a brand new version of onthesamepage) in 3 months. Depends on the project type and on the person, I guess.


First time I came across nullitics and it looks quite nice (GDPR, no cookies and all). Do you do any marketing? Seems you never posted it on HN ..

Also I like your blog. Articles like re-implementing Vue and React and KVM are quite instructive.


Yes. Nothing fancy from workflow. I pay for and use Goland because I find it so good for refactoring... worth the expense over VSCode.

Generally I use standard library, with the exception being github.com/gorilla/mux Gorilla Mux for routing because it removes so much boilerplate.

I do however use Python for all HTTP integration tests. With requests + voluptuous its so much more productive than doing them in Go, which I had previously done.


How do you access your database? How do you do migrations? How do you do end to end testing? How do you do fixtures? How do you do user input validations and error reporting? How do you do translations and 18n in general? Do you have any kind of admin ui? How do you handle assets? How do you do ajax calls? How do you send emails? How do you handle general error reporting to sentry, or similar?

Go is great for systems programing, building kubernetes, CLIs, etc.

It is very far from being a good idea to use it for general web development. Right tool for the job and such.


Go is also great for building performant APIs (REST or RPC).

I agree is not ideal if you want a full-blown monolith web app. In that case a typical MVC framework will save you weeks.


I agree only in that it is performant, but from a purely computational point of view.

Even if it is just a rest api, you still need a database/ORM layer, a validation framework, a migrations system, a way to document it, etc.

So, from a developers life quality and company economics point of view, django or rails are way, way more performant, but not as cool I agree.

Sure, if you're building Facebook or google Go might be the best option.


All of that is already built via libraries. Talking about facebook, they released an ORM a a while ago[1] and it has support for all the things you mention.

[1] https://github.com/ent/ent


Yep. I write code in vim, run tests and orchestrate things with Make and I deploy to Google Cloud Run. I used to use k8s.

I write monoliths and render mostly HTML back to the client. I have a few json endpoints around for m2m APIs or to power search boxes here and there.

The main thing I’m hacking on at the moment is https://clubman.app other things are listed at https://notbad.software

A relatively up to date skeleton of my apps is at https://github.com/davidbanham/doubleboiler


Yup.

My personal website was built using Go and Postgres. I did a lot of it from scratch using the standard library and very few dependencies.

I have my own deployment process using a makefile, git tags, and rsync. Migrations are just a set of sql files checked into the project.

This works pretty well for me since I'm the only developer on the project.

Here's my "tech" page with some information on the website: https://dwayne.xyz/tech

And the portfolio page for the website (on the website): https://dwayne.xyz/project/dwayne.xyz


I've created or inherited a few small web services (small, self-contained pieces shared by multiple apps or broken off for load management reasons). I would say Go is pretty good for this, some very nice performance wins were had easily.

I have very little temptation to use it for a whole application though. Unless you are already a Go shop I would advise anyone to just get better at making Ruby, Python, PHP, or JavaScript back ends that are more performant.


I enjoy Go for web development. I pretty much use the standard libary + Gorilla. I have few complaints, it's a little more verbose than Python but it feels more robust, easier to deploy and I like the performance. The code is easy to read.


Working on a new project and part of it is web development, we're moving forward with some pain.

We use Fiber (https://gofiber.io) as web framework and Pongo2 (https://github.com/flosch/pongo2) as template engine. The Go/Fiber parts are ok, the pain is template engine.

- Pongo2 syntax is like Django/Jinja2, but not as easy as Jinja2. I use Python+Jinja2 for years in production, it's so easy to use and troubleshoot.

- No builtin i18n support. You can find some blog posts or articles introduce pongo2, but no one mentions i18n support/implementation like no one need it. We implemented our own i18n support, but still need a tool to extract strings from template files for translation.

- The macro syntax doesn't support specifying argument names while calling. e.g. `{{ my_macro("a", "b", "c") }}` is ok, but not `{{ my_macro(name1="a", name2="b", name3="c") }}`. It's hard to organize reusable HTML/CSS code snippets.

- Sometimes the custom macro is correct (syntax part), but it renders nothing in output html, but if i add the same pongo2 code in its own unittests files, it works. Didn't find a way to troubleshoot, no clue at all what the problem is.

Anyway, Go itself and the web framework are very good for web development now, just miss a Jinja2 for Go.


I work on a personal project split into multiple packages totaling about 60k lines.

The end result are two web applications that work as a backend and frontend for an ActivityPub link aggregator (similar to HN and old redddit).

I mostly develop in Goland as I use the debugger extensively, and I didn't want to spend the time to learn to use delve in the command line.

I tried to keep as much as possible a handmade approach, so I'm making use of the standard library over more fancy packages or frameworks.

In my specific case the biggest issue I had was with the protocol itself (ActivityPub) which allows for a large degree of flexibility in the structure of the JSON objects it passes around, a lot more than the default encoder in go allows for. I had to implement my own functionality for encoding/decoding JSON objects, and I'm currently working on adding similar functionality for binary encoding.

Links to the projects you can find in my bio.


Got a small starter template I use but it doesn't do much more than basic format/structure for db patterns etc.

Tools wise we use VSCode, have a good local Dev story and we migrated from sqlx to sqlc recently to speed things up.

We use gorilla mux and build API first with Vue for frontend. Really clean and simple stack with few moving parts.


Yes, monolithic Go RESTful JSON API services - we currently depend on go-swagger, SQLBoiler (PostgreSQL) and echo.

Workflow: we use VSCode with devContainers (docker-compose local dev env), our tasks are simply defined in a Makefile. Our high-lvl dev workflow is documented here: https://github.com/allaboutapps/go-starter/wiki/FAQ#how-does...

Difficulties: Nothing special actually. We switched from Node.js to Go in the beginning of 2020 and it's been a pleasure for our new projects (software agency). I thought it was going to be hard to onboard our staff / new hires to Go and our stack, but this really turned out to be a non issue.


I used Go to create different web apps. One example would be https://namesmith.io (shameless plug), which I created with the Revel framework.

Revel is often seen as anti-idiomatic because it's a whole framework but it is nice to get a web app going pretty fast (with Go). These days I have a lot more experience and I probably would choose echo or something similar. Not because I think that Revel is bad but because I have a lot more freedom with those.

For editing I mostly use Vim.

Generally I would say if you create web apps maybe choose something different from Go. It certainly can be easier/more comfortable. For APIs it's still great and one of the best choices IMO.


Go is a little low-level/obtuse for business logic and UI stuff. We use it for many of the gRPC services that our web apps consume. The more systems-y the service, the better the fit.


Consultant using Go in a few client projects. Both use build-in-Docker for stability and less CI surprises. One uses GRPC with Profobuf, another is using an event sourcing toolkit I have authored [0]. Personally I use VSCode with gopls which has been working great for quiet some time now. Ordinary make files for combined documentation and usage of common operations.

[0] https://github.com/looplab/eventhorizon


We use it. Gorilla mux (https://github.com/gorilla/mux) to route requests plus some in-house handler chains that log, check JWT tokens, etc. We have a Go client library which accesses the web API, so we can do testing without having to involve the frontend team; a combination of tests in the client library and some judicious curl commands is usually enough.


Yes, chose Go over Rust for a prototype API backend because Google Cloud docs offers code examples in Go :p Satisfied with Go performance, strongly prefer Goland over VS Code for better debugging. Considering switching to Java or .Net for the remaining logic development, I would (perhaps naively) like to explore functional programming patterns and the potential benefits of a "larger" ecosystem (Spring Data JDBC for example).


Yes, both for personal projects and at work. I write APIs in Go (and there's React on the UI side that talks to it). I use VS Code to develop and build as a Docker image.

At work the images are deployed on DC/OS, and for my personal projects I use Docker Compose.

The most difficult part (which isn't really that difficult) would probably be the actual deployment part, and that's not specific to Go.


Yes, we use go-gin for HTTP servers and middleware (really fast and easy to use) and gRPC+Protobuf for backend services with database access. For the frontend, we have one project that renders HTML just with Go templates, but that’s kinda clumsy and awkward to maintain. Our main webapp is built with Vue.js, and the gin server only checks auth and serves the index.html


Pretty much write my services following this

https://pace.dev/blog/2018/05/09/how-I-write-http-services-a...

Use sqlx to extend the std lib.

Have dropped using an orm.


IntelliJ Ultimate with the Go Plugin. Sometimes vim-go.

The api is defined with gRPC.io and offered as a gRPC api as well as a Rest api with JSON using grpc-gateway. Database is PostgreSQL using pgx. Caching via Resis or memcached. Building testing via a Makefile with junit and cobertura reports


Is it hard to deploy with gRPC, because of the HTTP2 requirement?


I'm a Node guy and don't know anything about Go, what's the recommended route to get started on Go for the web? Any specific framework in mind? I need WebSockets and I'm guessing Go can provide some good performance improvement over Node there.


Read the top comment.

You start with a Makefile and a main.go and from there on you invent the universe, starting from (almost) writing an http server.

Welcome to the future.


www.stackazam.com is a cloud application built with Go

I have started falling in love with coding/CS again with Go.

Our philosophy is to keep things close to the metal and not use layers as much as possible. Go enables you to follow with approach with the standard libraries that come with the language.

Problem with layers/frameworks is that while they seem to solve immediate problem quickly, layers will rear their ugly head down the road , making you feel helpless during debugging

We use standard libraries

database/sql for database html/template for UI

Only external package used so far is gin-gonic/gin for middleware&routing


We keep things as close to the bare metal as possible and avoid complex layers as the plague.

We have only negative experiences with frameworks and big layers. They solve problems quickly in the beginning, but they always end up causing problems. Years later, debugging strange errors, security issues, etc. The more layers you add the less useful and good the application becomes.

we use the standard library and a couple of slim and well written external libraries, such as sqlx and go-sql-driver.

I have written my own HTML form validator and custom error handler - once you get that done, web development in Go becomes MUCH easier.

We don't use ANY JavaScript on the front-end unless it is a minor custom enhancement to the UI (it must be able to run without). Everything is pure HTML and CSS.

However, I personally do find the HTML templating tedious, but I have always found templating stupid and annoying, this is not specific to Go. I prefer to write HTML inline in PHP (when I do PHP) i.e. the old fashion way. I hate templating in any language!

It's easy to make mistakes in Go HTML templates, make sure you test that part of your code well!

Writing big web applications from scratch is great though, and it's really fast in Go, faster than PHP, as long as you do it right! Documentation, documentation, documentation. Anyone who inherits your code, whether you're alone or on a team, needs to know and understand your thinking and rationale.

The main reason why projects fail when they build tailor made software is because of laziness regarding documentation.

The correct way is to regard missing documentation as a bug! Write the documentation WHEN you write the code. If you change the code, change the documentation right away, when you can still remember what you're doing and why - this is the most important part and why so many code bases are horrible to inherit. Missing or poor documentation.

Never use "clever" code, make code that is easy to read and understand. Don't worry too much about design patterns and philosophy, they mostly belong in the books and in theoretical discussions!

Web development in Go is not for everyone, it requires experience and thoroughness. The build fast, deploy and forget strategy - that most people use these days - doesn't belong in Go.

Go will reward you in the end with really good performance and very easy future maintenance. Nothing suddenly breaks because a third of the standard library has suddenly been changed in the next version upgrade, such as with PHP.

EDIT: Typo.


Nah my go to is node, although recently I used a PHP script and the simplicity for a quick job is pretty nice. At work it’s C#


yes! Jetbrains GoLand helps quite a bit with the more annoying parts of the language (GOPATH, remembering commands for tools, managing go modules, etc)

There are some small things about the language that can feel a little cumbersome (lack of generics for example) but largely happy with the language and the trade offs so far seem worth it.


Have you managed to get GoLand's IDE tests to work properly? I found that it imports only the file for the test but nothing else which causes errors due to "undefined" things (things defined in the package are not accessible as it only imported a single file). Other than that I'm a happy GoLand user


No issues with GoLand tests here, maybe edit your configuration and change the "Test kind" field from "File" to "Package" or "Directory".


We write most of our backend web services in Go, not really the frontend parts though.


emacs with lsp plugin for development. echo framework for server and standard library for other things.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: